RFR [9] 8176772: jar tool support to report automatic module names

Chris Hegarty chris.hegarty at oracle.com
Wed Mar 15 14:21:45 UTC 2017


It would be useful for the jar tool to report the automatic module
name that would be used if a regular jar file was put on the
module path ( so there is an easy way for developers to
determine the derived name ). 

One way to achieve this is to repurpose the somewhat
finger-some '--print-module-descriptor’ option, to report
the automatic module name if the jar file does not contain
a module-info.class. Given this, we should then probably
give the option a better name, say ‘--describe-module’ (
similar to that of jmod's ‘describe’ subcommand ), e.g. 

 $ touch resource 
 $ jdk/bin/jar --create --file foo-6.jar resource 
 $ jdk/bin/jar --describe-module --file foo-6.jar 
 No module descriptor found. Derived automatic module: foo at 6 

It is also useful for the jar tool to indicate when a jar is not
suitable to use as an automatic module, e.g. 

 $ jdk/bin/jar --create --file ttt.jar T.class 
 $ jdk/bin/jar --describe-module --file ttt.jar 
 Unable to derive module descriptor for: ttt.jar 
 T.class found in top-level directory (unnamed package not allowed in module)

Webrev:

  http://cr.openjdk.java.net/~chegar/8176772.00/
  https://bugs.openjdk.java.net/browse/JDK-8176772

Note: it is a deliberate decision to not print the synthesised
module descriptor since the toString is not all that informative
for an automatic module. The name is the most pertinent
piece of information.

-Chris.


More information about the jigsaw-dev mailing list