diff options
author | David Daney <ddaney@avtrex.com> | 2006-11-20 19:43:25 +0000 |
---|---|---|
committer | David Daney <daney@gcc.gnu.org> | 2006-11-20 19:43:25 +0000 |
commit | e9057fe4ee3c43a4f89d75dd104230f46103c1a6 (patch) | |
tree | 498eea3594dee3465b56175369df6bf680de8bc9 /libjava/testsuite/libjava.lang/Throw_3.java | |
parent | d5b118856781e237fad3bef8b8a0193964a3f670 (diff) | |
download | gcc-e9057fe4ee3c43a4f89d75dd104230f46103c1a6.zip gcc-e9057fe4ee3c43a4f89d75dd104230f46103c1a6.tar.gz gcc-e9057fe4ee3c43a4f89d75dd104230f46103c1a6.tar.bz2 |
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
Diffstat (limited to 'libjava/testsuite/libjava.lang/Throw_3.java')
-rw-r--r-- | libjava/testsuite/libjava.lang/Throw_3.java | 41 |
1 files changed, 41 insertions, 0 deletions
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; + } +} |