mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +00:00
add a couple of test cases to NullPointer.java
This commit is contained in:
parent
8ed2bb9dbb
commit
a0a8c554d5
@ -2,10 +2,33 @@ public class NullPointer {
|
|||||||
private int x;
|
private int x;
|
||||||
private Object y;
|
private Object y;
|
||||||
|
|
||||||
|
private static void throw_(Object o) {
|
||||||
|
o.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void throwAndCatch(Object o) {
|
||||||
|
try {
|
||||||
|
o.toString();
|
||||||
|
throw new RuntimeException();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
throw_(null);
|
||||||
|
throw new RuntimeException();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
throwAndCatch(null);
|
||||||
|
|
||||||
// invokeinterface
|
// invokeinterface
|
||||||
try {
|
try {
|
||||||
((Runnable) null).run();
|
((Runnable) null).run();
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -13,6 +36,7 @@ public class NullPointer {
|
|||||||
// invokevirtual
|
// invokevirtual
|
||||||
try {
|
try {
|
||||||
((Object) null).toString();
|
((Object) null).toString();
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -20,6 +44,7 @@ public class NullPointer {
|
|||||||
// arraylength
|
// arraylength
|
||||||
try {
|
try {
|
||||||
int a = ((byte[]) null).length;
|
int a = ((byte[]) null).length;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -27,6 +52,7 @@ public class NullPointer {
|
|||||||
// iaload
|
// iaload
|
||||||
try {
|
try {
|
||||||
int a = ((byte[]) null)[42];
|
int a = ((byte[]) null)[42];
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -34,6 +60,7 @@ public class NullPointer {
|
|||||||
// aaload
|
// aaload
|
||||||
try {
|
try {
|
||||||
Object a = ((Object[]) null)[42];
|
Object a = ((Object[]) null)[42];
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -41,6 +68,7 @@ public class NullPointer {
|
|||||||
// getfield (int)
|
// getfield (int)
|
||||||
try {
|
try {
|
||||||
int a = ((NullPointer) null).x;
|
int a = ((NullPointer) null).x;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -48,6 +76,7 @@ public class NullPointer {
|
|||||||
// getfield (Object)
|
// getfield (Object)
|
||||||
try {
|
try {
|
||||||
Object a = ((NullPointer) null).y;
|
Object a = ((NullPointer) null).y;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -55,6 +84,7 @@ public class NullPointer {
|
|||||||
// iastore
|
// iastore
|
||||||
try {
|
try {
|
||||||
((byte[]) null)[42] = 42;
|
((byte[]) null)[42] = 42;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -62,6 +92,7 @@ public class NullPointer {
|
|||||||
// aastore
|
// aastore
|
||||||
try {
|
try {
|
||||||
((Object[]) null)[42] = null;
|
((Object[]) null)[42] = null;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -69,6 +100,7 @@ public class NullPointer {
|
|||||||
// putfield (int)
|
// putfield (int)
|
||||||
try {
|
try {
|
||||||
((NullPointer) null).x = 42;
|
((NullPointer) null).x = 42;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -76,6 +108,7 @@ public class NullPointer {
|
|||||||
// putfield (Object)
|
// putfield (Object)
|
||||||
try {
|
try {
|
||||||
((NullPointer) null).y = null;
|
((NullPointer) null).y = null;
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -85,6 +118,7 @@ public class NullPointer {
|
|||||||
synchronized ((Object) null) {
|
synchronized ((Object) null) {
|
||||||
int a = 42;
|
int a = 42;
|
||||||
}
|
}
|
||||||
|
throw new RuntimeException();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user