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

Type checking verifier fails to reject assignment from array to an interface

    Details

    • Subcomponent:
    • Resolved In Build:
      b85

      Backports

        Description

        JVMS 4.10.1.2 says
        "Array types are subtypes of Object. The intent is also that array types are subtypes of Cloneable and java.io.Serializable.

        isJavaAssignable(arrayOf(_), class('java/lang/Object', BL)) :-
            isBootstrapLoader(BL).

        isJavaAssignable(arrayOf(_), X) :-
            isArrayInterface(X).

        isArrayInterface(class('java/lang/Cloneable', BL)) :-
            isBootstrapLoader(BL).

        isArrayInterface(class('java/io/Serializable', BL)) :-
            isBootstrapLoader(BL)."

        However, typechecker allows array to be assigned to arbitrary interface. E.g. this code passes verification
        public static Method castToIntf:"([Ljava/lang/Object;)Ljava/lang/Iterable;"
            stack 1 locals 1
        {
            aload_0;
            areturn;
        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hseigel Harold Seigel
                  Reporter:
                  slukyanov Stanislav Lukyanov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: