diff --git a/test/NullPointer.java b/test/NullPointer.java index c09dc83340..6c6e5c7b50 100644 --- a/test/NullPointer.java +++ b/test/NullPointer.java @@ -2,10 +2,33 @@ public class NullPointer { private int x; 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) { + try { + throw_(null); + throw new RuntimeException(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + + throwAndCatch(null); + // invokeinterface try { ((Runnable) null).run(); + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -13,6 +36,7 @@ public class NullPointer { // invokevirtual try { ((Object) null).toString(); + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -20,6 +44,7 @@ public class NullPointer { // arraylength try { int a = ((byte[]) null).length; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -27,6 +52,7 @@ public class NullPointer { // iaload try { int a = ((byte[]) null)[42]; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -34,6 +60,7 @@ public class NullPointer { // aaload try { Object a = ((Object[]) null)[42]; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -41,6 +68,7 @@ public class NullPointer { // getfield (int) try { int a = ((NullPointer) null).x; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -48,6 +76,7 @@ public class NullPointer { // getfield (Object) try { Object a = ((NullPointer) null).y; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -55,6 +84,7 @@ public class NullPointer { // iastore try { ((byte[]) null)[42] = 42; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -62,6 +92,7 @@ public class NullPointer { // aastore try { ((Object[]) null)[42] = null; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -69,6 +100,7 @@ public class NullPointer { // putfield (int) try { ((NullPointer) null).x = 42; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -76,6 +108,7 @@ public class NullPointer { // putfield (Object) try { ((NullPointer) null).y = null; + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); } @@ -85,6 +118,7 @@ public class NullPointer { synchronized ((Object) null) { int a = 42; } + throw new RuntimeException(); } catch (NullPointerException e) { e.printStackTrace(); }