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

Lookup::defineHiddenClass should throw UnsupportedClassVersionError if the given bytes are of an unsupported major or minor version

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 15
    • 15
    • core-libs

      Tested method: MethodHandles.Lookup defineHiddenClass
      Assertion: After C is derived, it is linked by the Java Virtual Machine. Linkage occurs as specified in JVMS 5.4.3:
         "Otherwise, if the purported representation is not of a supported major or minor version (§4.1), loading throws an instance of UnsupportedClassVersionError."

      Expected exception:
      UnsupportedClassVersionError - if bytes is not of a supported major or minor version

      Thrown:
      java.lang.IllegalArgumentException: Unsupported class file major version 100
      at java.base/jdk.internal.org.objectweb.asm.ClassReader.<init>(ClassReader.java:215)
      at java.base/jdk.internal.org.objectweb.asm.ClassReader.<init>(ClassReader.java:197)
      at java.base/jdk.internal.org.objectweb.asm.ClassReader.<init>(ClassReader.java:183)
      at java.base/java.lang.invoke.MethodHandles$Lookup.validateAndGetClassName(MethodHandles.java:2029)
      at java.base/java.lang.invoke.MethodHandles$Lookup.makeHiddenClassDefiner(MethodHandles.java:2102)
      at java.base/java.lang.invoke.MethodHandles$Lookup.defineHiddenClass(MethodHandles.java:1961)
      at test.UCVExpected.testCase(UCVExpected.java:38)
      at test.UCVExpected.main(UCVExpected.java:53)

      Despite the correct meaning of the message, the exception itself does not follow the specification.

      The HiddenClass is:
      --"--
      package test;

      super public final class TestClass01n05 version 100:0
      {
      public Method "<init>":"()V" stack 1 locals 1
      {
      aload_0;
      invokespecial Method java/lang/Object."<init>":"()V";
      return;
      }

      } // end Class TestClass01n05
      --"--

            mchung Mandy Chung
            lkuskov Leonid Kuskov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: