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

Javac performs flows analysis on already translated classes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 7
    • tools
    • b34
    • unknown
    • generic
    • Not verified

        STEP TO REPRODUCE THE PROBLE

        class Y extends W {}
        class W extends Z {}

        class Z {
           static void m(Z z) {
               W w = (W)z;
           }
        }

        put all the classes in a single file (e.g. Test.java) and then execute the command:
        javac Test.java -Xlint:all -XDverboseCompilePolicy

        EXPECTED BEHAVIOUR

        compilation passes with no warning

        ACTUAL BEHAVIOR

        the compiler generates a warning:

        Test.java:6: warning: [cast] redundant cast to W
               W w = (W)z;
                           ^


        It seems like Z's flow analysis is executed *after* Y's erasure - that is when Z itself has already been recursively erased.

              mcimadamore Maurizio Cimadamore
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: