mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-09 01:47:19 +08:00
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
73 lines
1.1 KiB
Java
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");
|
|
}
|
|
}
|