Discover modulename

Alan Bateman Alan.Bateman at
Thu Aug 25 10:51:26 UTC 2016

On 25/08/2016 11:26, Robert Scholte wrote:

> Hi,
> In an old thread I asked this before and got the following answer:
> "One way is `jar --file foo.jar -p`. That will print the module 
> descriptor when the JAR file is a modular JAR. There is API support 
> for reading the binary form of the module declaration too."
> With the renaming of the arguments I assume it is now:
> jar --file foo.jar --print-module-descriptor
> However, this gives me an exception on the asm-6.0_ALPHA.jar
> d:\jdk-9\bin\jar --file asm-6.0_ALPHA.jar --print-module-descriptor
> java.lang.module.InvalidModuleDescriptorException: Index into constant 
> pool out of range
>         at 
> java.lang.module.ModuleInfo.invalidModuleDescriptor(java.base at 9-ea/
I can't think how the CLI update could cause this. Is there an ASM 
generated module-info.class in the picture? I wonder if this is main 
line JDK 9 vs. the Jigsaw EA builds where the binary representation has 

> :
> How about jars without module descriptor? Is there a commandline 
> option to discover what the name of an automodule will be? I could 
> guess the name, but I'd prefer to show the calculated name.
`java --list-modules` might help. Also it's easy to derive the module 
name from the name of the JAR file, all the details are in the 
ModuleFinder.of(Path...) javadoc.


More information about the jigsaw-dev mailing list