Skip to content

Commit 51b1d38

Browse files
committed
Add test for ClassCastException
The new test checks that a ClassCastException is correctly caught if the catch block specifies one of its superclasses.
1 parent 200017a commit 51b1d38

9 files changed

+32
-0
lines changed
197 Bytes
Binary file not shown.
197 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class A {}
2+
3+
class B {}
4+
5+
public class ClassCastExceptionTest {
6+
public static void main(String args[]) {
7+
try {
8+
Object a = new A();
9+
B b = (B)a;
10+
}
11+
catch (Exception exc) {
12+
assert false;
13+
}
14+
}
15+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package java.lang;
2+
3+
public class ClassCastException extends RuntimeException {
4+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package java.lang;
2+
3+
public class RuntimeException extends Exception {
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
ClassCastExceptionTest.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file ClassCastExceptionTest.java line 12 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring

0 commit comments

Comments
 (0)