-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b92
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8143534 | emb-9 | Maurizio Cimadamore | P3 | Resolved | Fixed | team |
Following the fix for JDK-8071291, some operations for union types started to behave strangely; for instance the following code should be rejected by javac:
interface Foo<X> { }
class A extends Exception implements Foo<A> { }
class B extends Exception implements Foo<B> { }
interface D { }
class Test {
<Z> void test(boolean cond) {
try {
if (cond) {
throw new A();
} else {
throw new B();
}
} catch (A | B ex) {
Foo<Integer> fa = (Foo<Integer>)ex;
}
}
}
Following the fix, this code started to pass (this was failing in JDK 7 and was crashing in 8).
interface Foo<X> { }
class A extends Exception implements Foo<A> { }
class B extends Exception implements Foo<B> { }
interface D { }
class Test {
<Z> void test(boolean cond) {
try {
if (cond) {
throw new A();
} else {
throw new B();
}
} catch (A | B ex) {
Foo<Integer> fa = (Foo<Integer>)ex;
}
}
}
Following the fix, this code started to pass (this was failing in JDK 7 and was crashing in 8).
- backported by
-
JDK-8143534 Subtle semantics changes for union types in cast conversion
-
- Resolved
-
- relates to
-
JDK-8071291 Compiler crashes trying to cast UnionType to IntersectionClassType
-
- Closed
-