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

generics: javac generares "new" of wrong class

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 1.4.1
    • 5.0
    • tools
    • hopper
    • generic
    • solaris_7

    Backports

      Description

        Under some circumstances the generic compiler calls "new"
        on the wrong class but calls the correct constructor.
        The mismatch fails verification.



        frog:~/workspaces/test/Generic3 $ cat -n T.java
             1 class List<T> {}
             2 class ArrayList<T> extends List<T> {}
             3
             4 class T
             5 {
             6 public static void main(String[] ps)
             7 {
             8 List<String> list = getList();
             9 }
            10
            11 public static List<String> getList()
            12 {
            13 return new ArrayList();
            14 }
            15 }
        frog:~/workspaces/test/Generic3 $ newjavac -gj T.java
        Note: T.java uses unchecked operations.
        Note: Recompile with -warnunchecked for details.
        frog:~/workspaces/test/Generic3 $ /net/frog/gafter/gjc-work/j2se/build/solaris-sparc/bin/java T
        Exception in thread "main" java.lang.VerifyError: (class: T, method: getList signature: ()LList;) Call to wrong initialization method
        frog:~/workspaces/test/Generic3 $ jdis T.class
        super class T
        {


        Method "<init>":"()V"
                stack 1 locals 1
        {
                        aload_0;
                        invokespecial Method java/lang/Object."<init>":"()V";
                        return;
        }

        public static Method main:"([Ljava/lang/String;)V"
                stack 1 locals 2
        {
                        invokestatic Method getList:"()LList;";
                        astore_1;
                        return;
        }

        public static Method getList:"()LList;"
                stack 2 locals 0
        {
                        new class List; // ********* OOPS
                        dup;
                        invokespecial Method ArrayList."<init>":"()V";
                        areturn;
        }

        } // end Class T

        Attachments

          Issue Links

            Activity

              People

                gafter Neal Gafter
                gafter Neal Gafter
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: