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

JSR292: IncompatibleClassChangeError in LambdaForm for CharSequence.toString() method handle type converter

    Details

    • Subcomponent:
    • Introduced In Build:
      b109
    • Introduced In Version:
      8
    • Resolved In Build:
      b02
    • Verification:
      Verified

      Backports

        Description

        Compilation of LambdaForm CharSequence.toString() MH type converter produces incorrect bytecode.

        Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface java.lang.CharSequence, but class was expected
        at java.lang.invoke.LambdaForm$MH/707806938.convert(LambdaForm$MH:1000001)
        at java.lang.invoke.LambdaForm$MH/317983781.invokeExact_MT(LambdaForm$MH:1000010)
        at TestCharSequence.main(TestCharSequence.java:13)

          static java.lang.Object convert(java.lang.Object, java.lang.Object);
            flags: ACC_STATIC
            Code:
              stack=1, locals=2, args_size=2
                 0: aload_1
                 1: invokevirtual #16 // InterfaceMethod java/lang/CharSequence.toString:()Ljava/lang/String;
                 4: areturn

        CharSequence is an interface, so invokevirtual fails to invoke toString method and throws ICCE.

        The test case passes fine in jdk7.

        Filed against hotspot/compiler (and not core-libs/java.lang.invoke), because initial analysis shows that VM returns wrong info when resolving corresponding MemberName:
        jdk/src/share/classes/java/lang/invoke/MemberName.java:965
                        m = MethodHandleNatives.resolve(m, lookupClass);

        before: m = java.lang.CharSequence.toString()String/invokeInterface
        after: m = java.lang.CharSequence.toString()String/invokeVirtual

        ILW = HLH = P2
        I = H = regression against jdk7
        L = L = very unlikely: (1) interface on boot class path; (2) overrides a method from Object; (3) MH type is converted; (4) MH invoked enough to be compiled into bytecode
        W = H = none

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  vlivanov Vladimir Ivanov
                  Reporter:
                  vlivanov Vladimir Ivanov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  10 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: