diff options
Diffstat (limited to 'libjava/testsuite/libjava.lang/Array_3.java')
| -rw-r--r-- | libjava/testsuite/libjava.lang/Array_3.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.lang/Array_3.java b/libjava/testsuite/libjava.lang/Array_3.java new file mode 100644 index 00000000000..f8b7ded4685 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Array_3.java @@ -0,0 +1,59 @@ +// Test to make sure null arrays throw the right execption + +public class Array_3 +{ + static Object foo () + { + return null; + } + + static int[] bar () + { + return null; + } + + public static void main(String args[]) + { + boolean ok = false; + int nn = 0; + + try + { + int[] x = (int[])foo(); + nn = x.length; + } + catch (NullPointerException _) + { + ok = true; + } + if (!ok) + throw new RuntimeException("test failed"); + + ok = false; + try + { + int[] x = bar(); + nn = x.length; + } + catch (NullPointerException _) + { + ok = true; + } + if (!ok) + throw new RuntimeException("test failed"); + + ok = false; + try + { + int[] x = bar(); + nn = x[0]; + } + catch (NullPointerException _) + { + ok = true; + } + + if (!ok || nn != 0) + throw new RuntimeException("test failed"); + } +} |

