Class DisambiguateTypeAnnotations


  • public final class DisambiguateTypeAnnotations
    extends java.lang.Object
    Disambiguate annotations on field, parameter, and method return types that could be declaration or type annotations.

    Given a declaration like private @A int x; or @A private int x;, there are three possibilities:

    1. @A is a declaration annotation on the field.
    2. @A is a TYPE_USE annotation on the type.
    3. @A sets TYPE_USE and FIELD targets, and appears in the bytecode as both a declaration annotation and as a type annotation.

    This can't be disambiguated syntactically (note that the presence of other modifiers before or after the annotation has no bearing on whether it's a type annotation). So, we wait until constant binding is done, read the @Target meta-annotation for each ambiguous annotation, and move it to the appropriate location.