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.