Results 1 to 3 of 3
  1. #1
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Hooking/debugging around System.exit(...)?

    I'm using a library that catches a NPE somewhere inside itself, prints a stack trace, and calls System.exit(...). (It's Sun's CodeModel API, in case you're curious.)

    If it were my own code throwing the NPE, my usual tactic would be to print some debug statements to find out what's null. Obviously I can't do that, short of modifying the library source.

    I know nothing about Java debuggers. Is there a tool I can use to examine what's going on?
    Get in the habit of using standard Java naming conventions!

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Hooking/debugging around System.exit(...)?

    I know nothing about Java debuggers.
    Now looks like a good time to learn!

    Set up a "break point" just before the NPE occurs and then "step" through the code "inspecting" the values of variables. A debugger will allow the code to run until a particular line is hit (== a break point), then it allows you to execute one line at a time (== stepping) and, at each point will display the value of variables or expressions you choose (== inspecting).

    This depends on the library code being suitable for use by the debugger, but, if so, it would seem the way to go. Most IDEs offer a debugger.

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Hooking/debugging around System.exit(...)?

    Well... I cheated and found the source for the library. Learning to use the debugger will have to wait for another day. Turns out I forgot an "if" statement... I was creating CodeModel methods with null names.

    Also, the library wasn't catching the exception. My example build script was calling my main class, and I forgot that the main class catches all exceptions. Late-night brain fart.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Exit System
    By jboy in forum New To Java
    Replies: 5
    Last Post: 09-14-2009, 09:27 AM
  2. Avoiding system.exit()
    By swati.jyoti in forum New To Java
    Replies: 5
    Last Post: 07-01-2009, 11:17 AM
  3. System.exit 0 or 1?
    By antgaudi in forum New To Java
    Replies: 3
    Last Post: 11-13-2008, 07:33 PM
  4. system.exit(..)
    By ramakanta.majhi in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 02:28 AM
  5. help with System.exit (1) function call
    By katie in forum Advanced Java
    Replies: 2
    Last Post: 08-06-2007, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •