Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException when running jpackage task with secondaryLauncher #210

Closed
xzel23 opened this issue Feb 28, 2022 · 7 comments
Closed

ClassCastException when running jpackage task with secondaryLauncher #210

xzel23 opened this issue Feb 28, 2022 · 7 comments
Labels
JDK Issue This is an issue with the JDK; it can't be fixed by the plugin

Comments

@xzel23
Copy link
Collaborator

xzel23 commented Feb 28, 2022

I am trying to create a jpackage with two launchers like this:

  launcher {
       name = 'DocDiff'
       moduleName = 'docdiff'
       mainClass = 'com.dua3.doc.app.docdiff.fx.Main'
       noConsole = true
       jvmArgs = [ '-Xmx3g' ]
   }

   secondaryLauncher {
       name = 'ddiff'
       moduleName = 'docdiff'
       mainClass = 'com.dua3.doc.app.docdiff.Main'
       noConsole = false
   }

this results in java.lang.ClassCastException: class java.util.ImmutableCollections$List12 cannot be cast to class java.lang.String. It works when I create just a single launcher.

Stacktrace when adding '--verbose' to jpackage.imageOptions:

[09:48:05.084] 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')
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.lambda$getPathListParameter$5(LauncherData.java:309)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.getPathParam(LauncherData.java:271)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.getPathListParameter(LauncherData.java:308)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.getModulePath(LauncherData.java:293)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.createModular(LauncherData.java:135)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.create(LauncherData.java:115)
        at jdk.jpackage/jdk.jpackage.internal.StandardBundlerParam.lambda$static$0(StandardBundlerParam.java:84)
        at jdk.jpackage/jdk.jpackage.internal.BundlerParamInfo.fetchFrom(BundlerParamInfo.java:114)
        at jdk.jpackage/jdk.jpackage.internal.BundlerParamInfo.fetchFrom(BundlerParamInfo.java:88)
        at jdk.jpackage/jdk.jpackage.internal.CfgFile.initFromParams(CfgFile.java:50)
        at jdk.jpackage/jdk.jpackage.internal.AbstractAppImageBuilder.writeCfgFile(AbstractAppImageBuilder.java:63)
        at jdk.jpackage/jdk.jpackage.internal.MacAppImageBuilder.prepareApplicationFiles(MacAppImageBuilder.java:307)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.createAppBundle(AppImageBundler.java:172)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:91)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
        at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
        at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)
[09:48:05.086] jdk.jpackage.internal.PackagerException: 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')
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:96)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
        at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
        at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)
Caused by: 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')
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.lambda$getPathListParameter$5(LauncherData.java:309)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.getPathParam(LauncherData.java:271)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.getPathListParameter(LauncherData.java:308)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.getModulePath(LauncherData.java:293)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.createModular(LauncherData.java:135)
        at jdk.jpackage/jdk.jpackage.internal.LauncherData.create(LauncherData.java:115)
        at jdk.jpackage/jdk.jpackage.internal.StandardBundlerParam.lambda$static$0(StandardBundlerParam.java:84)
        at jdk.jpackage/jdk.jpackage.internal.BundlerParamInfo.fetchFrom(BundlerParamInfo.java:114)
        at jdk.jpackage/jdk.jpackage.internal.BundlerParamInfo.fetchFrom(BundlerParamInfo.java:88)
        at jdk.jpackage/jdk.jpackage.internal.CfgFile.initFromParams(CfgFile.java:50)
        at jdk.jpackage/jdk.jpackage.internal.AbstractAppImageBuilder.writeCfgFile(AbstractAppImageBuilder.java:63)
        at jdk.jpackage/jdk.jpackage.internal.MacAppImageBuilder.prepareApplicationFiles(MacAppImageBuilder.java:307)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.createAppBundle(AppImageBundler.java:172)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:91)
        ... 4 more

I am still undecided if this is a problem with the jlink plugin (2.24.4) or the JDK (openjdk 17.0.2 on MaOS). I tried several JDK distributions (Oracle OpenJDK, Zulu, etc.).

@optyfr
Copy link

optyfr commented Apr 16, 2022

I'm getting the same problem on Windows with plugin 2.25.0 and OpenJDK 17.0.2, this does not happen when setting -Dbadass.jlink.jpackage.home to jdk 14
either syntax did change for jpackage, either jpackage for java 17 is broken with secondary launchers

@xzel23
Copy link
Collaborator Author

xzel23 commented Apr 17, 2022

Happens with all OpenJDK 17 and 18 builds I tried (Oracle, Zulu, Bellsoft) on both Windows and MacOS. When I dig into the exception stack trace, it looks like an errr in OpenJDK. I didn't have the time to reproduce without this plugin yet, and the process of submitting OpenJDK bugs still is a mystery to me.

@Isfirs
Copy link

Isfirs commented Sep 9, 2022

Bump.

Any progress on this? I am getting the same error and I could pin point it to the usage of the secondaryLauncher section

@airsquared
Copy link
Collaborator

airsquared commented Jun 14, 2023

Created a bug report at github.com/airsquared/jpackage_error

@airsquared
Copy link
Collaborator

airsquared commented Jul 20, 2023

Ended up fixing this myself at openjdk/jdk#14840, which was just merged. I also created back port PRs for JDK 21 and 20 at openjdk/jdk21u#120 and openjdk/jdk20u#86, respectively.

@xzel23
Copy link
Collaborator Author

xzel23 commented Jul 20, 2023

Wow, thank you! That's great news.

@airsquared
Copy link
Collaborator

Now that my PRs for JDK 21 and 17 were finally merged, the fix will be in JDK 21.0.1 and JDK 17.0.10.

@airsquared airsquared added the JDK Issue This is an issue with the JDK; it can't be fixed by the plugin label Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JDK Issue This is an issue with the JDK; it can't be fixed by the plugin
Projects
None yet
Development

No branches or pull requests

4 participants