Skip to content

Commit 6609f45

Browse files
committed
Add tests for NullPointerException on virtual call or array access
1 parent 273600e commit 6609f45

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed
566 Bytes
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
assertion at file test\.java line 9 function java::test\.main:\(\)V bytecode-index 12: FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
This test checks that accessing an array member, cf. a getfield or setfield bytecode,
12+
can produce a NullPointerException.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
public class test {
3+
public static void main () {
4+
try {
5+
int[] array = null;
6+
int x = array[0];
7+
}
8+
catch(NullPointerException e) {
9+
assert false;
10+
}
11+
}
12+
}
222 Bytes
Binary file not shown.
587 Bytes
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
test.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
assertion at file test\.java line 9 function java::test\.main:\(\)V bytecode-index 10: FAILURE
8+
--
9+
^warning: ignoring
10+
--
11+
This test ensures that attempting a virtual call against a null pointer can produce a NullPointerException,
12+
even when there are no field accesses inside the method or inspection of its class identifier to trigger one.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
public class test {
3+
public static void main () {
4+
try {
5+
A a = null;
6+
a.f();
7+
}
8+
catch(NullPointerException e) {
9+
assert false;
10+
}
11+
}
12+
}
13+
14+
class A {
15+
16+
public void f() {}
17+
18+
}

0 commit comments

Comments
 (0)