NullPointerException causing JVM to crash

X

Xiaolei Li

Hi,

I'm running into this peculiar problem where the JVM crashes. My
program uses JNI, specifically JRex [1]. The details are probably too
much to explain here, but it basically uses the Mozilla browser to do
certain things.

Anyway, after I initialize and open the browser through JNI, whenever a
NullPointerException is generated in my Java code (which is separate
from the JRex code), it will cause the entire JVM to crash even when
it's suppose to be caught. For example, the following code snippet will
crash. I've tried some different types of Exceptions to catch (eg,
RuntimeException, Error), but none of them help.

================================================================
public class Dummy { public int item; }

Dummy obj = null;
try {
int temp = obj.item;
}
catch (Exception ex) {
System.err.println("Real null pointer");
}
================================================================

However, if I manually throw a NullPointerException such as below, it
will *not* cause the crash.

================================================================
try {
throw new NullPointerException("Manually thrown null pointer");
}
catch(Exception ex) {
System.err.println(ex.getMessage());
}
================================================================

Can someone give me some directions as to where the possible source of
this might be? Thank you.

[1] http://jrex.mozdev.org/
 
C

Chris Smith

Xiaolei Li said:
Anyway, after I initialize and open the browser through JNI, whenever a
NullPointerException is generated in my Java code (which is separate
from the JRex code), it will cause the entire JVM to crash even when
it's suppose to be caught. For example, the following code snippet will
crash. I've tried some different types of Exceptions to catch (eg,
RuntimeException, Error), but none of them help.

My guess is that something in the browser is installing a signal handler
for SIGSEGV, and this is interfering with the JVM's mechanism to catch
and handle NullPointerException. Can you prevent Mozilla from
installing signal handlers somehow?

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
G

Gordon Beaton

I'm running into this peculiar problem where the JVM crashes. My
program uses JNI, specifically JRex [1].
[...]

Can someone give me some directions as to where the possible source
of this might be?

My guess: your native code.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top