-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b34
-
unknown
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2194762 | OpenJDK6 | Jonathan Gibbons | P4 | Resolved | Fixed | b21 |
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.
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.
- backported by
-
JDK-2194762 Javac performs flows analysis on already translated classes
-
- Resolved
-
- relates to
-
JDK-6726015 JavaCompiler: replace desugarLater by compileStates
-
- Closed
-