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

[lworld] GeneratedMethodAccessor contains incorrect cast

    XMLWordPrintable

    Details

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

      Description

      The GeneratedMethodAccessor for a reflective call to TestNewAcmp.testEq02_1 contains an incorrect cast to LMyValue1 instead of QMyValue1, leading to JIT crashes (JDK-8270352) because the generated bytecode is not verified:

      45 checkcast 16 <compiler/valhalla/inlinetypes/MyValue1> 0
        256 bci: 45 ReceiverTypeData count(0) nonprofiled_count(0) entries(1)
                                          'compiler/valhalla/inlinetypes/MyValue1'(5120 1,00)
      48 invokevirtual 10 <compiler/valhalla/inlinetypes/TestNewAcmp.testEq02_1(Qcompiler/valhalla/inlinetypes/MyValue1;Qcompiler/valhalla/inlinetypes/MyValue1;)Z>
        312 bci: 48 VirtualCallData count(0) nonprofiled_count(0) entries(1)
                                          'compiler/valhalla/inlinetypes/TestNewAcmp'(5120 1,00)
                      argument types 0: stack(1) 'compiler/valhalla/inlinetypes/MyValue1'
                                          1: stack(2) 'compiler/valhalla/inlinetypes/MyValue1'
      51 invokestatic 52 <java/lang/Boolean.valueOf(Z)Ljava/lang/Boolean;>

      The following change "fixes" the problem:

      index 72bc6eb6e63..c34ce441441 100644
      --- a/src/java.base/share/classes/jdk/internal/reflect/MethodAccessorGenerator.java
      +++ b/src/java.base/share/classes/jdk/internal/reflect/MethodAccessorGenerator.java
      @@ -341,7 +341,7 @@ class MethodAccessorGenerator extends AccessorGenerator {
               for (int i = 0; i < parameterTypes.length; i++) {
                   Class<?> c = parameterTypes[i];
                   if (!isPrimitive(c)) {
      - asm.emitConstantPoolUTF8(getClassName(c, false));
      + asm.emitConstantPoolUTF8(getClassName(c, true));
                       asm.emitConstantPoolClass(asm.cpi());
                   }
               }


      45 checkcast 16 <Qcompiler/valhalla/inlinetypes/MyValue1;> 1
        256 bci: 45 ReceiverTypeData count(0) nonprofiled_count(0) entries(1)
                                          'compiler/valhalla/inlinetypes/MyValue1'(5120 1,00)
      48 invokevirtual 10 <compiler/valhalla/inlinetypes/TestNewAcmp.testEq02_1(Qcompiler/valhalla/inlinetypes/MyValue1;Qcompiler/valhalla/inlinetypes/MyValue1;)Z>
        312 bci: 48 VirtualCallData count(0) nonprofiled_count(0) entries(1)
                                          'compiler/valhalla/inlinetypes/TestNewAcmp'(5120 1,00)
                      argument types 0: stack(1) 'compiler/valhalla/inlinetypes/MyValue1'
                                          1: stack(2) 'compiler/valhalla/inlinetypes/MyValue1'

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mchung Mandy Chung
              Reporter:
              thartmann Tobias Hartmann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: