[lworld] C2: Incorrect type is used for array creation

XMLWordPrintable

      For this method:

      static Integer test(Integer[] a) {
          return a[0];
      }

      when being called from:

      static void run() {
          test(new Integer[1]);
      }

      Then the class check of a would fail and the method gets recompiled. If I change the method to:

      static Integer test(Integer[] a) {
          field = new Integer[1];
          return a[0];
      }

      Then it is clear what is the issue, the class that is put in the new array is:

      narrowklass: precise [precise java/lang/Integer: 0x0000759cf0007ff0 (java/io/Serializable,java/lang/Comparable,java/lang/constant/Constable,java/lang/constant/ConstantDesc):Constant:exact * (java/lang/Cloneable,java/io/Serializable): :Constant:exact:flat:refined_type *

      While the one that is used in the speculative type check is:

      narrowklass: precise [precise java/lang/Integer: 0x0000759cf0007ff0 (java/io/Serializable,java/lang/Comparable,java/lang/constant/Constable,java/lang/constant/ConstantDesc):Constant:exact * (java/lang/Cloneable,java/io/Serializable): :Constant:exact:flat:atomic:refined_type *

      (Notice the last part, one is flat:atomic, another is only flat)

      Furthermore, if I don't compile run, then there is no decompilation happening. It seems the compiler use a different klass pointer from the one used by the interpreter.

            Assignee:
            Quan Anh Mai
            Reporter:
            Quan Anh Mai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: