Hi, Joel,
I know it's been months since this patch was integrated. I apologize that I
had talked about contributing some changes in this area and then never
pulled through.

In any event, I had some questions about the patch and possibly some
suggestions for further changes before the API is "sealed" for Java 9 (not
sure if that has already happened or not):

   - I see you had to override the new method on most of AnnotatedType's
   sub-interfaces to indicate that it should return null. The new method
   really only applies to "declared types" and thus had to be spec'ed to
   return null for arrays, wildcards, and type variables.
   - With both java.lang.reflect.Type and javax.lang.model.type.TypeMirror,
   all actual instances will implement some sub-interfaces (or, in the case of
   Type -> Class, be an instance of a known concrete class). So usages can
   generally use instanceof tests to learn more about the object and then
   down-cast. However, when working with AnnotatedTypes, there is no such
   sub-interface for a non-parameterized declared type. So the type-switch
   idiom is left with a default that must make assumptions about the
   AnnotatedType instance (which could be invalidated by future API
   changes, like introduction of new sub-interfaces).

Given the above, I think it makes sense to introduce a new interface,
AnnotatedRawType, that extends AnnotatedType. Instead of having
getAnnotatedOwnerType() on AnnotatedType, it could just exist on
AnnotatedRawType and AnnotatedParameterizedType.


(FWIW, getting a development environment setup for Java 9 was very
difficult circa 12 months ago. I had made several changes in a local
checkout of the jdk8 repo. But I never got a chance to forward-patch my
changes to jdk9. Also, I'm a mercurial n00b, so lack of comfort with the
tools was a major impediment. Anyhow, I'd still like to contribute but was
stymied by the amount of free time it would take me to push through these
challenges. Maybe I'll get some motivation to revisit before it's too late
to contribute to jdk9.)




----
*Joshua Humphries*
jos...@bluegosling.com


On Tue, Nov 17, 2015 at 2:15 PM, Joel Borggrén-Franck <
joel.borggren.fra...@gmail.com> 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
>

Reply via email to