#ModuleAnnotations - some thoughts and an alternative implementation

Alan Bateman Alan.Bateman at oracle.com
Mon Jul 18 06:42:41 UTC 2016


On 17/07/2016 23:36, Peter Levart wrote:

> :
>
> Here's an alternative implementation that does not need to define the 
> class in the VM:
>
> http://cr.openjdk.java.net/~plevart/jdk9-jake/Module.annotations/webrev.02/ 
>
>
> It instead modifies AnnotationParser to use a special 
> AnnotationParser.ConstantPool interface which is implemented by two 
> classes: a classical reflection ConstantPool backed by VM and a 
> lightweight Java-only implementation which is used to parse 
> module-info.class. So while parsing module-info.class, the 
> RuntimeVisibleAnnotations attribute is extracted and memorized in 
> ModuleDescriptor. Together with the lightweight ConstantPool 
> implementation, they are used in Module to parse the annotations when 
> 1st requiested.
>
> It is more involved than current implementation, but it is also 
> lighter and might be extended to support - let's call them 
> annotation-descriptors - on ModuleDescriptor.
>
> What do you think?
One of the initial prototypes that we did was to have 
jdk.internal.reflect.ConstantPool backed by the constant pool in the 
module-info.class so that the raw annotations + constant pool could be 
used with the existing parser. So not too dissimilar to what you have in 
this patch.

With the proposal to keep things simple (in particular, not impacting 
ModuleDescriptor, Builder, ...) then it opened up the door for a much 
simpler implementations, hence the current implementation.

BTW: I see you've changed Module to implement GenericDeclaration rather 
than AnnotatedElement. I'm curious about.

-Alan


More information about the jigsaw-dev mailing list