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

jpackage does not work for module projects unless --module-path is specified

    XMLWordPrintable

Details

    • b08
    • generic
    • generic

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        Windows 10 and Linux OpenJDK20

        A DESCRIPTION OF THE PROBLEM :
        jpackage with multiple module launchers crashes unless the command line contains a trivial / unnecessary module path.
        Note that this bug is similar to the report mentioned in JDK-8306488 but isn't quite the same issue. The test case for JDK-8306488 has omitted --module-path when it should have added one (so is perhaps an issue with the test case), whereas in this example --module-path isn't needed at all but must be specified even though not needed.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        I have a large project with multiple modules, I built a JRE with jlink that contains every module used and pass that JRE to jpackage command so that no additional modules are required by jpackage. Fortunately I can reproduce simply by calling jpackage with a classname of module "java.base" and with the standard OpenJDK20 runtime. On WIndows / Linux start in empty directory:

           mkdir THIS_ISNT_NEEDED_BUT_JPACKAGE_FAILS_WITHOUT_IT
           
        Create a launcher specifying module from a package found in the runtime image (java.base in this case)

           echo module=java.base/classdoesnotmatter > launcher.properties

        On Windows I use OpenJDK as the runtime parameter - C:\java\jdk-20

        jpackage --name "TEST" --runtime-image C:\java\jdk-20 --type app-image --module java.base/classnotimportant --dest jpackage0.out

        jpackage --name "TEST" --runtime-image C:\java\jdk-20 --type app-image --module java.base/classnotimportant --add-launcher another=launcher.properties --dest jpackage1.out

        jpackage --name "TEST" --runtime-image C:\java\jdk-20 --type app-image --module java.base/classnotimportant --add-launcher another=launcher.properties --dest jpackage2.out --module-path THIS_ISNT_NEEDED_BUT_JPACKAGE_FAILS_WITHOUT_IT

        On Linux I use OpenJDK as the runtime parameter - /mnt/c/linux/jdk-20

        jpackage --name "TEST" --runtime-image /mnt/c/linux/jdk-20 --type app-image --module java.base/classnotimportant --dest jpackage3.out

        jpackage --name "TEST" --runtime-image /mnt/c/linux/jdk-20 --type app-image --module java.base/classnotimportant --add-launcher another=launcher.properties --dest jpackage4.out

        jpackage --name "TEST" --runtime-image /mnt/c/linux/jdk-20 --type app-image --module java.base/classnotimportant --add-launcher another=launcher.properties --dest jpackage5.out --module-path THIS_ISNT_NEEDED_BUT_JPACKAGE_FAILS_WITHOUT_IT


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        All 6 jpackage commands should generate app-image structure as the JRE runtime supplied contains the required module "java.base" that was specified by each launch configuration. [Obviously these apps won't run as the classnames are made up]

        ACTUAL -
        Two of the commands fail - runs for jpackage1.out and jpackage4.out both crash with exception:
        java.lang.ClassCastException: class java.util.ImmutableCollections$List12 cannot be cast to class java.lang.String (java.util.ImmutableCollections$List12 and java.lang.String are in module java.base of loader 'bootstrap')


        CUSTOMER SUBMITTED WORKAROUND :
        The workaround is to supply `--module-path` for an empty directory. That gets copied into the release and every launcher contains these unnecessary lines:
          java-options=--module-path
          java-options=$APPDIR\mods


        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                asemenyuk Alexey Semenyuk
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: