source: trunk/src/gcc/libjava/testsuite/libjava.lang/Array_3.java@ 141

Last change on this file since 141 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 870 bytes
Line 
1// Test to make sure null arrays throw the right execption
2
3public class Array_3
4{
5 static Object foo ()
6 {
7 return null;
8 }
9
10 static int[] bar ()
11 {
12 return null;
13 }
14
15 public static void main(String args[])
16 {
17 boolean ok = false;
18 int nn = 0;
19
20 try
21 {
22 int[] x = (int[])foo();
23 nn = x.length;
24 }
25 catch (NullPointerException _)
26 {
27 ok = true;
28 }
29 if (!ok)
30 throw new RuntimeException("test failed");
31
32 ok = false;
33 try
34 {
35 int[] x = bar();
36 nn = x.length;
37 }
38 catch (NullPointerException _)
39 {
40 ok = true;
41 }
42 if (!ok)
43 throw new RuntimeException("test failed");
44
45 ok = false;
46 try
47 {
48 int[] x = bar();
49 nn = x[0];
50 }
51 catch (NullPointerException _)
52 {
53 ok = true;
54 }
55
56 if (!ok || nn != 0)
57 throw new RuntimeException("test failed");
58 }
59}
Note: See TracBrowser for help on using the repository browser.