This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Some null pointer method invocations causes segmentation fault



The following program causes a segmentation fault when run, instead of
the NullPointerException one would expect.

--------
public class NullPointerExceptionTest {
    public static void main(String[] args) {
        ((Integer) null).intValue();
    }
}
--------

Starting
program: /home/debian/rolfwr/prg/testgcj/./NullPointerExceptionTest

[...]
Program received signal SIGSEGV, Segmentation fault.
0x400dfef9 in java.lang.Integer.intValue (this=null)
    at ../../../libjava/java/lang/Integer.java:60
60          return value;
Current language:  auto; currently java
(gdb) bt
#0  0x400dfef9 in java.lang.Integer.intValue (this=null)
    at ../../../libjava/java/lang/Integer.java:60
#1  0x804af63 in NullPointerExceptionTest.main (args=@8081ff0)
    at NullPointerExceptionTest.java:3
#2  0x4013160a in gnu::gcj::runtime::FirstThread::run (this=@8064ea0)
[...]

Other one-liners that trigger the same problem:

    ((String) null).length();
    ((java.util.Vector) null).size();
    Boolean ref = null; ref.booleanValue();

I've compiled/run with gcj/libgcj pulled from CVS on 27. March.
gcc version 2.96 20000327 (experimental) on i586-pc-linux-gnu

--
Rolf W. Rasmussen

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]