From e9057fe4ee3c43a4f89d75dd104230f46103c1a6 Mon Sep 17 00:00:00 2001 From: David Daney Date: Mon, 20 Nov 2006 19:43:25 +0000 Subject: Throw_3.java: New Test. * testsuite/libjava.lang/Throw_3.java: New Test. * testsuite/libjava.lang/Throw_3.out: Its expected output. From-SVN: r119023 --- libjava/testsuite/libjava.lang/Throw_3.java | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 libjava/testsuite/libjava.lang/Throw_3.java (limited to 'libjava/testsuite/libjava.lang/Throw_3.java') diff --git a/libjava/testsuite/libjava.lang/Throw_3.java b/libjava/testsuite/libjava.lang/Throw_3.java new file mode 100644 index 0000000..5d9a2dc --- /dev/null +++ b/libjava/testsuite/libjava.lang/Throw_3.java @@ -0,0 +1,41 @@ +// Check that a NPE likely thrown from the first instruction of a +// method (foo) is properly caught. +public class Throw_3 +{ + public static void main(String[] args) + { + Throw_3 al = new Throw_3(); + try + { + al.foo(null); + } + catch (NullPointerException npe) + { + StackTraceElement ste[] = npe.getStackTrace(); + StackTraceElement top = ste[0]; + if ("foo".equals(top.getMethodName())) + { + System.out.println("ok"); + return; + } + } + System.out.println("bad"); + } + + public int bar(int[] a) + { + System.out.println("Bar"); + return 5; + } + + /** + * If the second parameter ('this' being the first) is passed in a + * register, then the first machine instruction in foo is likely to + * fault when null is passed. + */ + public int foo(int[] a) + { + int l = a.length; + return l + l; + } +} -- cgit v1.1