Results 1 to 3 of 3
- 01-29-2012, 03:13 AM #1
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!
- 01-29-2012, 03:31 AM #2Moderator
- Join Date
- Feb 2009
- New Zealand
- Rep Power
Re: Hooking/debugging around System.exit(...)?I know nothing about Java debuggers.
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.
- 01-29-2012, 08:19 PM #3
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!
- By jboy in forum New To JavaReplies: 5Last Post: 09-14-2009, 08:27 AM
- By swati.jyoti in forum New To JavaReplies: 5Last Post: 07-01-2009, 10:17 AM
- By antgaudi in forum New To JavaReplies: 3Last Post: 11-13-2008, 07:33 PM
- By ramakanta.majhi in forum New To JavaReplies: 2Last Post: 06-14-2008, 01:28 AM
- By katie in forum Advanced JavaReplies: 2Last Post: 08-06-2007, 08:03 PM