Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8253761

Wrong URI syntax printed by jar --describe-module

    XMLWordPrintable

    Details

    • Subcomponent:
      jar
    • Introduced In Version:
      9
    • Resolved In Build:
      b19
    • CPU:
      generic
    • OS:
      generic

      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;
      }
      }}

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lancea Lance Andersen
              Reporter:
              cstein Christian Stein
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: