blob: f8b7ded4685d1712bbf31ca70ead571182709d31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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");
}
}
|