Finding module-info.class without loading a jar

Remi Forax forax at univ-mlv.fr
Sat Feb 24 14:53:01 UTC 2018



On February 24, 2018 12:33:25 PM UTC, Mark Raynsford <org.openjdk at io7m.com> wrote:
>On 2018-02-24T07:53:16 +0000
>Alan Bateman <Alan.Bateman at oracle.com> wrote:
>>
>> The JarFile API does this for you. Are you sure you've used the 
>> constructor that specifies the runtime version? Once you do that then
>
>> getJarEntry("module-info.class") will locate the module-info.class in
>
>> the versioned section. Use JarEntry::getRealName to satisfy yourself 
>> that it always locates the right one (say where you have a 
>> module-info.class in the top-level directory and one each in 
>> META-INF/versions/9 and META-INF/versions/10).
>
>Ah, thank you. I had completely overlooked this constructor.
>
>> ModuleDescriptor.read is an easy way to parse the module-info.class
>in 
>> case you need it.
>
>Yes, I'm planning to move to this from ASM.

The main difference between the ModuleDescriptor and the ModuleVisitor of ASM is that you can read the annotations with the ModuleVisitor.
So it may not worth having ASM as dependency.

Remi


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


More information about the jigsaw-dev mailing list