JDK-8153652 : Update javap to be multi-release jar aware
  • Type: Sub-task
  • Component: core-libs
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Withdrawn
  • Submitted: 2016-04-06
  • Updated: 2016-06-15
  • Resolved: 2016-06-15
Related Reports
Relates :  
Relates :  
Description
The javap tool must be updated to enable selection of versioned class files.

Currently 
     $ javap -cp version.jar version.Version

will display the attributes of the base entry in a multi-release jar file (i.e. version/Version.class).  If one wants to inspect versioned entries they need to specifically request a class through a jar url as in

     $ javap jar:file:version.jar\!/META-INF/versions/9/version/Version.class

What we'd like to do is add a command line option to select the appropriate version of the class.  

It turns out that javap already has such a command line option, -multi-release.  So one can select appropriate classes like this:

    $ javap -cp version.jar version.Version   (for the base version)
    $ javap -cp version.jar -multi-release 9 version.Version  (for the jdk 9 version)
    $ javap -cp version.jar -multi-release runtime version.Version   (also for the jdk 9 version since runtime is equivalent to 9 on                  jdk 9)

So all we really need to do is to document the option.
Comments
The class path semantics for javap are not a significant use case.
15-06-2016

Updating javap to be multi-release jar aware is not recommended. The use case in the description $ javap -cp version.jar version.Version should display the attributes for the base entry. Making javap multi-release aware would mean that the above use case could display different results depending on whether it's run on JDK 9 or JDK 10. That would be clearly confusing. It's best to always display a consistent result, that associated with the base class. Furthermore, the use case above is considered not a significant use case, and it's application is not recommended. Use a jar: URL scheme to directly address the desired class file in a multi-release jar. For example, use the following forms instead. $ javap jar:file:version.jar\!/version/Version.class $ javap jar:file:version.jar\!/META-INF/versions/9/version/Version.class
15-06-2016