-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
14
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
I have this app, which uses Java 14 with âenable-preview and records. If I turn it in to a normal non-modular jar, it works with both java -jar âenable-preview myapp.jar, and with a native image built with jpackage. However, when i turn it into a modular jar, I can still launch it with java âenable-preview âmodule-path ... âmodule ..., but when I try to create a native image using jpackage usign the same modular flags, launching it fails. I get a dialog box saying âFailed to launch JVMâ, and if I enable âwin-console when I build it and relaunch it, it tells me this:
Exception in thread "main" java.lang.ClassFormatError: Invalid constant pool index 31 for name in Record attribute in class file net/jevring/frequencies/v2/input/KeyTimings$Note
at java.base/java.lang.ClassLoader.defineClass2(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at frequencies/net.jevring.frequencies.v2.input.KeyTimings.<init>(Unknown Source)
at frequencies/net.jevring.frequencies.v2.Thief.<init>(Unknown Source)
at frequencies/net.jevring.frequencies.v2.Main.main(Unknown Source)
Note, above, is a record. I tried moving it out to a separate class, and I still got the same error. When I converted Note to a normal class, it started complaining about the next record it cound.
I know that itâs picking up the âenable-preview java option, because when I omit that, it complains about the class file version being wrong.
Since I can run it just fine using âjava -jarâ, and it works fine under all other circumstances, I must conclude that thereâs something wrong with the intersection of modular jars and jpackage.
Iâve googled around plenty, and I havenât found anything that might help me. Iâm not sure if this is a call for help or a bug report, though Iâd like to consider it the latter =)
I put what I had on a branch: https://bitbucket.org/jevring/frequencies/branch/java-modules
I realize itâs not a small self-contained example that replicates the issue, and for that Iâm sorry. If someone is interested about this, I could try to make one.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a modular application with at least one record.
Compile it to a jar
Verify that it works by launching "java -jar --enable-preview myjar.jar"
Pack it into an app image using "jpackage --win-console --type app-image --module-path target\myjar.jar --module my-module --java-options --enable-preview --verbose"
Launch this image and receive the error about "Invalid constant pool index" mentioned in the description
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application should launch just as when I launch it using "java -jar --enable-preview myjar.jar"
ACTUAL -
An exception, as per the description, complaining about "Invalid constant pool index"
---------- BEGIN SOURCE ----------
https://bitbucket.org/jevring/frequencies/branch/java-modules
---------- END SOURCE ----------
FREQUENCY : always
I have this app, which uses Java 14 with âenable-preview and records. If I turn it in to a normal non-modular jar, it works with both java -jar âenable-preview myapp.jar, and with a native image built with jpackage. However, when i turn it into a modular jar, I can still launch it with java âenable-preview âmodule-path ... âmodule ..., but when I try to create a native image using jpackage usign the same modular flags, launching it fails. I get a dialog box saying âFailed to launch JVMâ, and if I enable âwin-console when I build it and relaunch it, it tells me this:
Exception in thread "main" java.lang.ClassFormatError: Invalid constant pool index 31 for name in Record attribute in class file net/jevring/frequencies/v2/input/KeyTimings$Note
at java.base/java.lang.ClassLoader.defineClass2(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at frequencies/net.jevring.frequencies.v2.input.KeyTimings.<init>(Unknown Source)
at frequencies/net.jevring.frequencies.v2.Thief.<init>(Unknown Source)
at frequencies/net.jevring.frequencies.v2.Main.main(Unknown Source)
Note, above, is a record. I tried moving it out to a separate class, and I still got the same error. When I converted Note to a normal class, it started complaining about the next record it cound.
I know that itâs picking up the âenable-preview java option, because when I omit that, it complains about the class file version being wrong.
Since I can run it just fine using âjava -jarâ, and it works fine under all other circumstances, I must conclude that thereâs something wrong with the intersection of modular jars and jpackage.
Iâve googled around plenty, and I havenât found anything that might help me. Iâm not sure if this is a call for help or a bug report, though Iâd like to consider it the latter =)
I put what I had on a branch: https://bitbucket.org/jevring/frequencies/branch/java-modules
I realize itâs not a small self-contained example that replicates the issue, and for that Iâm sorry. If someone is interested about this, I could try to make one.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a modular application with at least one record.
Compile it to a jar
Verify that it works by launching "java -jar --enable-preview myjar.jar"
Pack it into an app image using "jpackage --win-console --type app-image --module-path target\myjar.jar --module my-module --java-options --enable-preview --verbose"
Launch this image and receive the error about "Invalid constant pool index" mentioned in the description
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application should launch just as when I launch it using "java -jar --enable-preview myjar.jar"
ACTUAL -
An exception, as per the description, complaining about "Invalid constant pool index"
---------- BEGIN SOURCE ----------
https://bitbucket.org/jevring/frequencies/branch/java-modules
---------- END SOURCE ----------
FREQUENCY : always