gcc/libjava/testsuite/libjava.lang/Array_3.java
Andrew Haley 6ac0c1e36f inline.java: New file.
2002-07-02  Andrew Haley  <aph@redhat.com>

        * libjava.lang/inline.java: New file.
        * libjava.lang/inline.out: Likewise.

        * libjava.lang/Array_3.java: Add another case.

From-SVN: r55186
2002-07-02 17:21:10 +00:00

73 lines
1.1 KiB
Java

// 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:1");
ok = false;
try
{
int[] x = bar();
nn = x.length;
}
catch (NullPointerException _)
{
ok = true;
}
if (!ok)
throw new RuntimeException("test failed:2");
ok = false;
try
{
int[] x = bar();
nn = x[0];
}
catch (NullPointerException _)
{
ok = true;
}
if (!ok || nn != 0)
throw new RuntimeException("test failed:3");
ok = false;
try
{
int[] x = (int[])null;
nn = x.length;
}
catch (NullPointerException _)
{
ok = true;
}
if (!ok)
throw new RuntimeException("test failed:4");
}
}