Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Debug Uncaught Exceptions  (Read 886 times)
0 Members and 1 Guest are viewing this topic.
Offline Best Username Ever

Junior Member





« Posted 2012-10-14 00:47:53 »

Is it possible to automatically pause a program when/before an exception is thrown? I've seen it in IDEs for other languages, but I just noticed I've never used it with Java. Here's an explanation of how I would want such a feature to work: Whenever something like a NullReferenceException, DivideByZeroException(Error?), or IndexOutOfBoundsException occurs, the program should pause, go back to the statement that caused the exception (so that continuing would cause the same exception to occur again), show the exception message, and give you access to normal debugging features like the stacktrace and local variable view as if you had stopped at that point via a breakpoint or by stepping.

NetBeans (an older version) has a "Stop on uncaught exception" option, but it does not work this way and I am not sure what it is meant to do. It would be much more convenient than the only alternative I can think of: Crash the program when the first uncaught exception occurs, read its stack trace, put a conditional breakpoint on the line, and hope you can reproduce the original problem. (Which is trivially easy for some experimental code I was working on, but impossible to reproduce in a game.)
Offline Waterwolf

Junior Member


Medals: 3



« Reply #1 - Posted 2012-10-14 00:54:43 »

IIRC Eclipse does this automatically if you start the program in debug mode.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2012-10-14 02:18:55 »

Yup, if you run the program in debug mode, as soon as an instance of Throwable (and its descendants) is created, the thread it's in is paused and highlights the line.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Best Username Ever

Junior Member





« Reply #3 - Posted 2012-10-14 15:24:02 »

What's the name of the feature? Does it exist in some version of NetBeans?
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-10-14 15:30:21 »

Yes this exists in debug mode in Netbeans and Eclipse.

Offline Best Username Ever

Junior Member





« Reply #5 - Posted 2012-10-14 15:49:21 »

I can confirm it's not a default feature in NetBeans 6.7. It's about time I update. Whatever reason I installed an old version for is probably fixed and I don't care about my plugins anymore... But it still seems strange that that feature would be added so recently. Any idea why I could not find it through a search engine or what search terms I should have used?
Offline Varkas
« Reply #6 - Posted 2012-10-15 13:45:41 »

IIRC Netbeans just shows the stack trace in the debugger console and you can jump from there to the source lines. I assume it's nowhere mentioned because it seems to be such an integral feature of any debugger. Maybe my memory betrays me though, wouldn't be the first time.

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #7 - Posted 2012-10-15 14:07:16 »

IIRC Netbeans just shows the stack trace in the debugger console and you can jump from there to the source lines. I assume it's nowhere mentioned because it seems to be such an integral feature of any debugger. Maybe my memory betrays me though, wouldn't be the first time.
That's different from actually breaking and halting execution on an uncaught exception though - just jumping to the source code after it's crashed won't let you inspect the local state that caused it.

There is this bug that suggests it was broken but is now fixed in NB 7.0: http://netbeans.org/bugzilla/show_bug.cgi?id=190527

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (59 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!