Find JSRs
Submit this Search

Ad Banner

Summary of changes to JSR 269 packages

Package javax.annotation.processing

The initial inputs can include module-info files. Such files are represented by ModuleElement objects. However, new module-element source and class files cannot be created through the Filer API. In the Filer API, the syntax of the "name" parameters of the create methods is expanded to allow a leading "mod-name/".

If an explicit module is not specified, the Filer API attempts to infer a module. If a module cannot be inferred, an exception is thrown.

The syntax of Processor.getSupportedAnnotationTypes is also expanded to allow an optional leading module name and slash.

For processors written to run both pre- and post-modules, the recommendation is that the supported annotation type name include the module prefix and rely on the code in AbstractProcessor.getSupportedAnnotationTypes to strip out the module name when a source level earlier than 9 is being used.

New overloaded methods RoundEnvironment.getElementsAnnotatedWithAny allow multiple annotations to be searched for in a single call.

The annotation type Generated is added to javax.annotation.processing. This annotation type is intended to be a replacement for javax.annotation.Generated.

Package javax.lang.model.*

The direct support for modeling modules proceeded mostly as expected for modeling a new language construct in the API: a new ModuleElement type was added, a corresponding new visitModule method was added to the ElementVisitor interface, and a new MODULE ElementKind was added too. The ModuleElement interface extends Element, QualifiedNameable, and also AnnotatedConstruct.

The API support for modules throughout the API is similar to the support for packages.

A new visitor interface is added to assist processing module directives.

The methods added to interfaces in this release generally use the new-in-Java-8 feature of default methods to provide some nominal implementation and provide better source compatibility for implementers of the interfaces. This included the new ElementVisitor.visitModule method method. The existing one-argument "visit" methods in the AnnotationValueVisitor, ElementVisitor, and TypeVisitor interfaces were also upgraded to be default methods.

Besides a new constant for RELEASE_9, SourceVersion gained additional isKeyword and isName methods parameterized by a SourceVersion argument.

The behavior of getEnclosingElement for a PackageElement is dependent on the source version being used for the annotation processing run. When modules are present, a module encloses a package. When modules are not present, null is returned for the enclosing element of a package as done previously.

The Elements utility interface has additions for name-based look-ups of types, packages, and modules. A method is also added to return the origin of a construct, that is, if the construct is explicitly declared in the source, implicitly declared in the source, synthesized by the compiler, etc.

The constructors of 6-era visitor classes have been deprecated since that source level is also deprecated.

The overall specification had a cleanup pass, obsolete statements removed, more @jls tags, etc.