RFR: JDK-8057804: AnnotatedType interfaces provide no way to get annotations on owner type

Claes Redestad claes.redestad at oracle.com
Thu Nov 19 13:07:13 UTC 2015


Hi Joel,

looks good. I see a CCC has been filed.

Nits:
In AnnotatedTypeFactory.java, newly introduced 
EMPTY_TYPE_ANNOTATION_ARRAY could be used to replace a few occurrences 
of new TypeAnnotation[0] in the code above).

In TypeAnnotation.java:
New method popLocation(byte tag) seems to be unused, and popLocation() 
is only used from popAllLocations(byte tag), so it might suffice to only 
keep popAllLocations:

         public LocationInfo popAllLocations(byte tag) {
             LocationInfo l = this;
             int depth = l.depth;
             while(depth > 0 && l.locations[depth - 1].tag == tag) {
                 depth--;
             }
             if (depth != l.depth) {
                 Location[] res = new Location[depth];
                 System.arraycopy(this.locations, 0, res, 0, depth);
                 return new LocationInfo(depth, res);
             }
             return l;
         }

Not a reviewer, easy to ignore. :-)

/Claes

On 2015-11-17 20:15, Joel Borggrén-Franck wrote:
> Hi,
>
> When reflecting over annotated types, there is currently no way to get
> the potentially annotated owner of a type. For example, given you have
> an instance of '@A Outer . @B Inner' you can't traverse it to get '@A
> Outer' .
>
> This API addition fixes this. Because both parameterized and
> non-generic types can have an owner, this addition goes into the base
> AnnotatedType interface together with a default implementation. CCC
> has been filed.
>
> The parsing code and annotated type factory had to be fixed to deal
> with navigating inside nested types.
>
> Bug:       https://bugs.openjdk.java.net/browse/JDK-8057804
> Webrev: http://cr.openjdk.java.net/~rbackman/jbf/8057804/webrev.00/
>
>
> (OCA is signed and processed).
>
> Cheers
> /Joel




More information about the core-libs-dev mailing list