1 // Check that NullPointerExceptions thrown from library code are
2 // caught. This detects a number of failures that can be caused by
3 // libgcj being built incorrectly. In particular, we ensure that a
4 // SEGV in native (i.e. C++) code in libgcj is handled correctly.
6 // Regrettably, we cannot guarantee that Double.parseDouble() will
7 // always be native code, or that it will never be inlined. It could
8 // be argued that we should add a method to libgcj that will be
9 // guaranteed forever to be native, but I'm reluctant to add to the
10 // library for the sole purpose of performing this test.
14 public static Throwable
obj()
19 public static String
str()
26 public static void main (String
[] args
)
28 // This NullPointerException will, at the time of writing, be
29 // thrown from Java code in libgcj.
32 java
.util
.Vector v
= new java
.util
.Vector (null);
33 System
.out
.println ("fail: no exception thrown");
35 catch (NullPointerException _
)
37 System
.out
.println ("1");
41 System
.out
.println ("fail: " + _
);
43 // This one will, at the time of writing, be thrown from C++
47 d
= Double
.parseDouble(str());
48 System
.out
.println ("fail: no exception thrown");
50 catch (NullPointerException _
)
52 System
.out
.println ("2");
56 System
.out
.println ("fail: " + _
);