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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:

      Description

      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
      --"--

        Attachments

          Activity

            People

            • Assignee:
              mchung Mandy Chung
              Reporter:
              lkuskov Leonid Kuskov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: