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

jdeps --multi-release --print-module-deps fails if module-info.class in different versioned directories

    XMLWordPrintable

    Details

    • Resolved In Build:
      b26

      Backports

        Description

        To reproduce, create 2 module source folders with a simple module-info.java class:

            ├───mod.bar
            │ module-info.java
            │
            ├───mod.baz
            │ module-info.java

        Compile and create 2 jar files, each with the module-info class under a separate version:

            $ javac --module-source-path . -d out -m mod.bar
            $ javac --module-source-path . -d out -m mod.baz
            $ jar --create --file mod-bar.jar --release 11 -C 'out/mod.bar' module-info.class
            $ jar --create --file mod-baz.jar --release 12 -C 'out/mod.baz' module-info.class

        Then run jdeps over both jars with the higher of the 2 release versions passed to multi-release:

            jdeps --multi-release 12 --print-module-deps mod-bar.jar mod-baz.jar

        This will sometimes produce an exception (just spam it in the console a few times, and you should see it):

        Exception in thread "main" java.lang.Error: java.util.concurrent.ExecutionException: com.sun.tools.jdeps.MultiReleaseException
        at jdk.jdeps/com.sun.tools.jdeps.DependencyFinder.waitForTasksCompleted(DependencyFinder.java:271)
        at jdk.jdeps/com.sun.tools.jdeps.DependencyFinder.parse(DependencyFinder.java:133)
        at jdk.jdeps/com.sun.tools.jdeps.DepsAnalyzer.run(DepsAnalyzer.java:129)
        at jdk.jdeps/com.sun.tools.jdeps.ModuleExportsAnalyzer.run(ModuleExportsAnalyzer.java:74)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask$ListModuleDeps.run(JdepsTask.java:1047)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:574)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:533)
        at jdk.jdeps/com.sun.tools.jdeps.Main.run(Main.java:64)
        at jdk.jdeps/com.sun.tools.jdeps.Main$JDepsToolProvider.run(Main.java:73)
        at java.base/java.util.spi.ToolProvider.run(ToolProvider.java:138)
        at main.JDepsMultiRelease.main(JDepsMultiRelease.java:12)
        Caused by: java.util.concurrent.ExecutionException: com.sun.tools.jdeps.MultiReleaseException
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
        at jdk.jdeps/com.sun.tools.jdeps.DependencyFinder.waitForTasksCompleted(DependencyFinder.java:267)
        ... 10 more
        Caused by: com.sun.tools.jdeps.MultiReleaseException
        at jdk.jdeps/com.sun.tools.jdeps.VersionHelper.add(VersionHelper.java:62)
        at jdk.jdeps/com.sun.tools.jdeps.ClassFileReader$JarFileReader.readClassFile(ClassFileReader.java:360)
        at jdk.jdeps/com.sun.tools.jdeps.ClassFileReader$JarFileIterator.hasNext(ClassFileReader.java:402)
        at jdk.jdeps/com.sun.tools.jdeps.DependencyFinder.lambda$parse$5(DependencyFinder.java:179)
        at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

         The reason that an exception is only reported _sometimes_ is the result of a data-race in jdep's VersionHelper. See: https://bugs.openjdk.java.net/browse/JDK-8277166 (applying the fix I suggested in the comments there makes this 100% reproducible).

        2 jars defining a module-info.class in a different versioned directory is valid as far as I know (it's not a case of split packages). So, an exception should not be thrown in this case I think.
            

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                mchung Mandy Chung
                Reporter:
                jvernee Jorn Vernee
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: