Jakarta Annotations

Last updated

Jakarta Annotations (CA; formerly Common Annotations for the Java Platform or JSR 250) is a part of Jakarta EE. Originally created with the objective to develop Java annotations (that is, information about a software program that is not part of the program itself) for common semantic concepts in the Java SE and Java EE platforms that apply across a variety of individual technologies. It was envisioned that various JSRs would use annotations to enable a declarative style of programming. It would be especially valuable to have consistency within the Java EE component JSRs, but it is also valuable to allow consistency between Java EE and Java SE.

Contents

Description and purpose

JSR 250, as a Java Specification Request, has the objective to define a set of annotations that address common semantic concepts and therefore can be used by many Java EE and Java SE components. This is to avoid redundant annotations across those components. JSR 250 was released on 11 May 2006. As Declarative annotation-driven configuration is more and more used in Java frameworks and applications, e.g. Spring makes more components of its framework configurable via annotations, the importance of JSR 250 is likely to increase in the future.

Dependencies to other JSRs

JSR 250 depends on JSR 175 and therefore also on Java SE 5.0

List of annotations

The namespaces within jakarta.* was previously part of namespace javax.*, being moved once Eclipse Foundation was given control of Java Platform, Enterprise Edition. [1]

AnnotationPackageDescription
@Generatedjakarta.annotationMarks source code that has been generated (i.e. not written by a user, or automatically generated by a computer).
@Resourcejakarta.annotationMarks a class, method, or field as a reference to a resource.
@Resourcesjakarta.annotationDeclares reference to resources, as a container for multiple resource declarations.
@PostConstructjakarta.annotationMarks a method to indicate that it must be executed after dependency injection to perform initialization, i.e. the method must be invoked before the class is used.
@PreDestroyjakarta.annotationMarks a method as a callback notification to indicate the instance is in the process of being removed by the container, i.e. the method is used to release resources held by the instance.
@Priorityjakarta.annotationMarks any program element to indicate in what order they should be used.
@Nonnulljakarta.annotationMarks any element that cannot be null.
@Nullablejakarta.annotationMarks any element that has the explicit possibility of being null.
@RunAsjakarta.annotationDefines the security role of the application during execution in a Jakarta EE container.
@RolesAllowedjakarta.annotation.securityMarks a method to specify security roles permitted to access the method.
@PermitAlljakarta.annotation.securityMarks a method to specify that all security roles may access the method.
@DenyAlljakarta.annotation.securityMarks a method to specify that no security roles may access the method.
@DeclareRolesjakarta.annotation.securitySpecifies security roles used by the application.
@DataSourceDefinitionjakarta.annotation.sqlDefines a container DataSource that is registered with Java Naming and Directory Interface (JNDI).
@DataSourceDefinitionsjakarta.annotation.sqlDeclares a container DataSource, acting as a container for multiple data source declarations.

There was previously an annotation, @ManagedBean, located in jakarta.annotation, which was historically used to declare a Managed Bean which are container managed objects that support a small set of basic services such as resource injection, lifecycle callbacks and interceptors. However, it has been removed. [2] [3]

Implementation

All non-Java EE JSR 250 annotations were added to the Java SE with version 6 (Generated, PostConstruct, PreDestroy, Resource, Resources). They are located in the package javax.annotation. They were subsequently deprecated in Java SE 9 and removed in Java SE 11, however, they are effectively continued, being renamed to jakarta.annotation in Jakarta EE 9.

References

  1. "Jakarta Annotations". Jakarta EE . Retrieved 13 August 2025.
  2. "Jakarta Annotations API 1.3.5 API". Jakarta EE . Retrieved 13 August 2025.
  3. "Jakarta Annotations". Jakarta EE . Retrieved 13 August 2025.