RFR: 8268575: Annotations not visible on model elements before they are generated

Srikanth Adayapalam sadayapalam at openjdk.java.net
Thu Dec 2 08:52:25 UTC 2021


On Thu, 2 Dec 2021 08:24:51 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:

> As an inadvertant side effect of JDK-8206325, the model was failing to expose a missing annotation type. Address this.

The code chunk that "gathers up the annotations into a map" in the method Annotate.annotateNow got surrounded/enclosed  by a check 

if (a.type.tsym.isAnnotationType()) {
}

as part of the fix for JDK-8206325 - this check is tighter than it ought to be.

javax.lang.model spec requires that 

If a program refers to a missing class or interface Xyz, the returned model must contain no less information than if the declaration of class or interface Xyz were assumed to be "class Xyz {}", "interface Xyz {}", "enum Xyz {}", "@interface Xyz {}", or "record Xyz {}".


This goal would be defeated by the check above and hence the present fix which relaxes it so we tolerate missing types and expose them in the model.

(It is worth calling out that annotation processing would not kick in if there are errors that could not be recovered from by generation of code from the processor)

-------------

PR: https://git.openjdk.java.net/jdk/pull/6662


More information about the compiler-dev mailing list