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

LauncherHelper.checkAndLoadMain closes jar file that's about to be re-opened

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • None
    • tools
    • b11

      LauncherHelper.getMainClassFromJar takes a String as parameter corresponding to a jar file where the "Main-Class" attribute needs to be determined. It returns a Class reference.

      However, it closes the jar file that the JDK has just spent time in opening and parsing (building CEN structure etc) :

      at java.base/java.util.zip.ZipFile$Source.release(ZipFile.java:1482)
      at java.base/java.util.zip.ZipFile$CleanableResource.run(ZipFile.java:804)
      at java.base/jdk.internal.ref.CleanerImpl$PhantomCleanableRef.performCleanup(CleanerImpl.java:178)
      at java.base/jdk.internal.ref.PhantomCleanable.clean(PhantomCleanable.java:133)
      at java.base/java.util.zip.ZipFile$CleanableResource.clean(ZipFile.java:728)
      at java.base/java.util.zip.ZipFile.close(ZipFile.java:837)
      at java.base/sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:676)
      at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:848)
      at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:756)

      The launcher process would benefit from a performance gain (avoid rebuilding the zip index) if the jar file remains opened. The Class returned is about to be loaded and the jar file will be opened again (with current code).

            cstein Christian Stein
            coffeys Sean Coffey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: