Better function header dump
[official-gcc.git] / libjava / testsuite / libjava.lang / Array_3.java
blobe94549a0f4ebddaab346ad133a6bde88ed4404e5
1 // Test to make sure null arrays throw the right execption
3 public class Array_3
5 static Object foo ()
7 return null;
10 static int[] bar ()
12 return null;
15 static int baz ()
17 int[] x = (int[])null;
18 int nn = x.length;
19 return 5;
22 public static void main(String args[])
24 boolean ok = false;
25 int nn = 0;
27 try
29 int[] x = (int[])foo();
30 nn = x.length;
32 catch (NullPointerException _)
34 ok = true;
36 if (!ok)
37 throw new RuntimeException("test failed:1");
39 ok = false;
40 try
42 int[] x = bar();
43 nn = x.length;
45 catch (NullPointerException _)
47 ok = true;
49 if (!ok)
50 throw new RuntimeException("test failed:2");
52 ok = false;
53 try
55 int[] x = bar();
56 nn = x[0];
58 catch (NullPointerException _)
60 ok = true;
63 if (!ok || nn != 0)
64 throw new RuntimeException("test failed:3");
66 ok = false;
67 try
69 int[] x = (int[])null;
70 nn = x.length;
72 catch (NullPointerException _)
74 ok = true;
76 if (!ok)
77 throw new RuntimeException("test failed:4");
79 ok = false;
80 try
82 nn = baz ();
84 catch (NullPointerException _)
86 ok = true;
88 if (!ok)
89 throw new RuntimeException("test failed:5");