Details
Description
The "jar --describe-module --file ..." command prints out the URI of a compiled module descriptor with wrong syntax: the position of `!` and `/` are swapped.
Expected syntax: "jar:<url>!/{entry}" as specified at https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/net/JarURLConnection.html
Line that produces the wrong URI syntax: "uri = "jar:" + uri + "/!" + entry.getName();" https://github.com/openjdk/jdk/blob/821bd08cd691fba338ba86b771b8573fd51c06c8/src/jdk.jartool/share/classes/sun/tools/jar/Main.java#L1740
*Demo*
{{
C:\Users\Sor>jar --describe-module --file Downloads\simplicissimus-d0e1d4c.jar
com.github.sormuras.simplicissimus@2-ea+d0e1d4c jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar/!module-info.class
requires java.base mandated
// Use URI printed above as an argument of javap
C:\Users\Sor>javap jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar/!module-info.class
Error: class not found: jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar/!module-info.class
// Replace "/!" with "!/" and it works
C:\Users\Sor>javap jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar!/module-info.class
Compiled from "module-info.java"
module com.github.sormuras.simplicissimus@2-ea+d0e1d4c {
requires java.base;
}
}}
Expected syntax: "jar:<url>!/{entry}" as specified at https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/net/JarURLConnection.html
Line that produces the wrong URI syntax: "uri = "jar:" + uri + "/!" + entry.getName();" https://github.com/openjdk/jdk/blob/821bd08cd691fba338ba86b771b8573fd51c06c8/src/jdk.jartool/share/classes/sun/tools/jar/Main.java#L1740
*Demo*
{{
C:\Users\Sor>jar --describe-module --file Downloads\simplicissimus-d0e1d4c.jar
com.github.sormuras.simplicissimus@2-ea+d0e1d4c jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar/!module-info.class
requires java.base mandated
// Use URI printed above as an argument of javap
C:\Users\Sor>javap jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar/!module-info.class
Error: class not found: jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar/!module-info.class
// Replace "/!" with "!/" and it works
C:\Users\Sor>javap jar:file:///C:/Users/Sor/Downloads/simplicissimus-d0e1d4c.jar!/module-info.class
Compiled from "module-info.java"
module com.github.sormuras.simplicissimus@2-ea+d0e1d4c {
requires java.base;
}
}}