NullPointerException causing JVM to crash

Discussion in 'Java' started by Xiaolei Li, Apr 26, 2005.

  1. Xiaolei Li

    Xiaolei Li Guest

    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/

    --
    Xiaolei Li | | www.xiaolei.org
    Xiaolei Li, Apr 26, 2005
    #1
    1. Advertising

  2. Xiaolei Li

    Chris Smith Guest

    Xiaolei Li <> wrote:
    > 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
    Chris Smith, Apr 26, 2005
    #2
    1. Advertising

  3. On Tue, 26 Apr 2005 20:43:21 +0000 (UTC), Xiaolei Li wrote:
    > 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

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Apr 26, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad

    ASPX page causing IE to crash

    Brad, May 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,114
  2. Tohru Kao
    Replies:
    3
    Views:
    416
    Neil Masson
    Jul 14, 2003
  3. Tohru Kao
    Replies:
    1
    Views:
    380
    Chris
    Jul 8, 2003
  4. C B
    Replies:
    3
    Views:
    2,056
    David Hilsee
    Aug 12, 2004
  5. asd
    Replies:
    2
    Views:
    454
    Andrew Thompson
    Jun 23, 2005
Loading...

Share This Page