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

jpackage with a modular application fails to load record class files even with --enable-preview

    XMLWordPrintable

Details

    • x86_64
    • windows_10

    Description

      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


      Attachments

        Activity

          People

            herrick Andy Herrick (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: