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

[lworld] [lw3] Test InlineTypeArrays.java fails because of incorrect instanceof behavior

XMLWordPrintable

      Test fails with the following stack trace:
      java.lang.RuntimeException: assertTrue: expected true, was false
              at jdk.test.lib.Asserts.fail(Asserts.java:594)
              at jdk.test.lib.Asserts.assertTrue(Asserts.java:486)
              at jdk.test.lib.Asserts.assertTrue(Asserts.java:472)
              at runtime.valhalla.inlinetypes.InlineTypeArray.testSanityCheckcasts(InlineTypeArray.java:289)
              at runtime.valhalla.inlinetypes.InlineTypeArray.run(InlineTypeArray.java:58)
              at runtime.valhalla.inlinetypes.InlineTypeArray.main(InlineTypeArray.java:47)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:568)
              at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
              at java.base/java.lang.Thread.run(Thread.java:831)


      The class file generated by javac seems correct:

      void testSanityCheckcasts();
          descriptor: ()V
          flags: (0x0000)
          Code:
            stack=2, locals=18, args_size=1
               0: iconst_1
               1: anewarray #276 // class "Qruntime/valhalla/inlinetypes/InlineTypeArray$MyInt;"
               4: astore_1
               5: aload_1
               6: instanceof #278 // class "[Ljava/lang/Object;"
               9: invokestatic #72 // Method jdk/test/lib/Asserts.assertTrue:(Z)V
              12: aload_1
              13: instanceof #280 // class "[Ljava/lang/Comparable;"
              16: invokestatic #72 // Method jdk/test/lib/Asserts.assertTrue:(Z)V
              19: aload_1
              20: instanceof #282 // class "[Lruntime/valhalla/inlinetypes/InlineTypeArray$MyInt;"

      But the implementation of the instanceof bytecode fails to recognize that InlineTypeArray$MyInt[] is a subtype of InlineTypeArray$MyInt.ref[].

            fparain Frederic Parain
            fparain Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: