-
Bug
-
Resolution: Fixed
-
P4
-
9
-
b46
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085314 | emb-9 | Maurizio Cimadamore | P4 | Resolved | Fixed | team |
Given the following program:
class S<T> { T t; }
class C { class I { }; }
class E extends S<C> {{
t = new C();
((C) t).new I() { };
}};
public class X {
public static void main(String[] args) { new E(); }
}
(the customer suggested workaround for https://bugs.openjdk.java.net/browse/JDK-8043741),
the compiler ends up creating an abstract syntax tree for class E whose textual representation
looks like:
class E extends S {
E() {
super();
}
{
t = new C();
new E$1(this, <*nullchk*>((C)(C)t));
}
}
i.e. there is a compiler inserted redundant type cast operation.
While this is harmless (in fact this redundant cast does not make it to class files being trimmed
by Gen.visitTypeCast), this is best avoided.
class S<T> { T t; }
class C { class I { }; }
class E extends S<C> {{
t = new C();
((C) t).new I() { };
}};
public class X {
public static void main(String[] args) { new E(); }
}
(the customer suggested workaround for https://bugs.openjdk.java.net/browse/JDK-8043741),
the compiler ends up creating an abstract syntax tree for class E whose textual representation
looks like:
class E extends S {
E() {
super();
}
{
t = new C();
new E$1(this, <*nullchk*>((C)(C)t));
}
}
i.e. there is a compiler inserted redundant type cast operation.
While this is harmless (in fact this redundant cast does not make it to class files being trimmed
by Gen.visitTypeCast), this is best avoided.
- backported by
-
JDK-8085314 Redundant type cast nodes in AST (follow up from JDK-8043741)
-
- Resolved
-
- duplicates
-
JDK-8148356 Typecastings are duplicated in byte code
-
- Closed
-
-
JDK-8201420 javac emits duplicate checkcast when calling Array.newInstance(Class, int) etc
-
- Closed
-