Skip to content

Commit 272bce3

Browse files
author
Daniel Kroening
authored
Merge pull request #506 from cristina-david/exception-handling
Java exception handling
2 parents 2245eb2 + 4a44668 commit 272bce3

File tree

123 files changed

+1636
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1636
-37
lines changed
Binary file not shown.

regression/cbmc-java/NullPointer3/NullPointer3.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ public static void main(String[] args)
44
{
55
throw null; // NULL pointer dereference
66
}
7-
87
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
CORE
22
NullPointer3.class
3-
--pointer-check --stop-on-fail
3+
--pointer-check
44
^EXIT=10$
55
^SIGNAL=0$
6-
^ file NullPointer3.java line 5 function java::NullPointer3.main:\(\[Ljava/lang/String;\)V bytecode_index 1$
6+
^.*Throw null: FAILURE$
77
^VERIFICATION FAILED$
88
--
99
^warning: ignoring
234 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
1 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 26 function.*: FAILURE$
7+
\*\* 1 of 9 failed \(2 iterations\)$
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class A extends Throwable {}
2+
class B extends A {}
3+
class C extends B {}
4+
class D extends C {}
5+
6+
public class test {
7+
public static void main (String arg[]) {
8+
try {
9+
D d = new D();
10+
C c = new C();
11+
B b = new B();
12+
A a = new A();
13+
A e = a;
14+
throw e;
15+
}
16+
catch(D exc) {
17+
assert false;
18+
}
19+
catch(C exc) {
20+
assert false;
21+
}
22+
catch(B exc) {
23+
assert false;
24+
}
25+
catch(A exc) {
26+
assert false;
27+
}
28+
}
29+
}
30+
241 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
875 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 12 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class A extends RuntimeException {}
2+
class B extends A {}
3+
class C extends B {}
4+
5+
public class test {
6+
static void foo() {
7+
try {
8+
A b = new A();
9+
throw b;
10+
}
11+
catch(A exc) {
12+
assert false;
13+
}
14+
}
15+
16+
public static void main (String args[]) {
17+
try {
18+
A a = new A();
19+
foo();
20+
}
21+
catch(B exc) {
22+
assert false;
23+
}
24+
}
25+
}
276 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
976 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 36 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
class A extends RuntimeException {
2+
int i=1;
3+
};
4+
5+
class B extends A {
6+
};
7+
8+
public class test {
9+
static int foo(int k) {
10+
try {
11+
if(k==0)
12+
{
13+
A a = new A();
14+
throw a;
15+
}
16+
else
17+
{
18+
A b = new A();
19+
throw b;
20+
}
21+
22+
}
23+
catch(B exc) {
24+
assert exc.i==1;
25+
}
26+
return 1;
27+
}
28+
29+
30+
public static void main (String args[]) {
31+
try {
32+
A a = new A();
33+
foo(6);
34+
}
35+
catch(A exc) {
36+
assert exc.i==2;
37+
}
38+
}
39+
}
241 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
641 Bytes
Binary file not shown.
740 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 12 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class A extends RuntimeException {}
2+
class B extends A {}
3+
class C extends B {}
4+
5+
class F {
6+
void foo() {
7+
try {
8+
B b = new B();
9+
throw b;
10+
}
11+
catch(B exc) {
12+
assert false;
13+
}
14+
}
15+
}
16+
17+
public class test {
18+
public static void main (String args[]) {
19+
try {
20+
F f = new F();
21+
f.foo();
22+
}
23+
catch(B exc) {
24+
assert false;
25+
}
26+
}
27+
}
241 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
405 Bytes
Binary file not shown.
740 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 25 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class A extends RuntimeException {}
2+
class B extends A {}
3+
class C extends B {}
4+
5+
class F {
6+
void foo() {
7+
try {
8+
B b = new B();
9+
throw b;
10+
}
11+
catch(B exc) {
12+
throw exc;
13+
}
14+
}
15+
}
16+
17+
public class test {
18+
19+
public static void main (String args[]) {
20+
try {
21+
F f = new F();
22+
f.foo();
23+
}
24+
catch(B exc) {
25+
assert false;
26+
}
27+
}
28+
}
241 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
858 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class A extends RuntimeException {}
2+
class B extends A {}
3+
class C extends B {}
4+
5+
public class test {
6+
public static void main (String args[]) {
7+
try {
8+
try {
9+
C c = new C();
10+
A a = new A();
11+
}
12+
catch(C exc) {
13+
assert false;
14+
}
15+
catch(B exc) {
16+
assert false;
17+
}
18+
}
19+
catch(A exc) {
20+
assert false;
21+
}
22+
23+
}
24+
}
251 Bytes
Binary file not shown.
Binary file not shown.
1006 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
test.class
3+
--function test.translate
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class InetAddress {}
2+
class InetSocketAddress {}
3+
4+
public class test {
5+
public String lookupPtrRecord(InetAddress address) {
6+
return "Foo";
7+
}
8+
9+
public InetAddress reverse(InetAddress address) {
10+
return address;
11+
}
12+
13+
public void translate(InetAddress address, int i) {
14+
try {
15+
String domainName = lookupPtrRecord(reverse(address));
16+
} catch (Exception e) {
17+
assert false;
18+
}
19+
}
20+
}
241 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
718 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
--function test.foo
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 18 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class A extends RuntimeException {}
2+
class B extends A {}
3+
class C extends B {}
4+
5+
public class test {
6+
static void foo (int x) {
7+
try {
8+
x++;
9+
}
10+
catch(A exc) {
11+
assert false;
12+
}
13+
14+
try {
15+
throw new B();
16+
}
17+
catch(B exc) {
18+
assert false;
19+
}
20+
}
21+
}
241 Bytes
Binary file not shown.
756 Bytes
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class A extends RuntimeException {}
2+
class B extends A {}
3+
4+
public class Test {
5+
void foo()
6+
{
7+
A a=new A();
8+
throw a;
9+
}
10+
void goo()
11+
{
12+
try
13+
{
14+
foo();
15+
assert false;
16+
}
17+
catch(B e)
18+
{
19+
assert false;
20+
}
21+
}
22+
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
--function Test.goo
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
234 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
771 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 15 function.*: FAILURE$
7+
^\*\* 1 of 5 failed \(2 iterations\)$
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class A extends Throwable {}
2+
class B extends A {}
3+
class C extends B {}
4+
5+
public class test {
6+
public static void main (String args[]) {
7+
try {
8+
B b = new B();
9+
throw b;
10+
}
11+
catch(C exc) {
12+
assert false;
13+
}
14+
catch(B exc) {
15+
assert false;
16+
}
17+
}
18+
}
234 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
216 Bytes
Binary file not shown.
751 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file test.java line 14 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring

0 commit comments

Comments
 (0)