Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 47023

Summary: debug breaks on caught exception on jdk 1.4.2
Product: [Eclipse Project] JDT Reporter: quartz quartz <quartz12h>
Component: DebugAssignee: Luc Bourlier <eclipse>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P2 CC: makoto_wada_jp
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
jdb debug trace
none
simple jdi code to show and solve the problem none

Description quartz quartz CLA 2003-11-19 13:43:08 EST
The sample code works fine in run mode.
When in debug mode, it runs without breaking, on jdk 1.4.1
but on jdk 1.4.2 it breakpoints the thread on some file not found exception.
As you resume, of course all is fine (time zone is not null, exception is caught
internally).

Basically, the problem is that eclipse breaks on the exception (which is not
breakpointed), The FNFE is caught internally in the jre.

Eclipse has always done that since any version of 1.4.2 are out. I just
installed a fresh 1.4.2_02b3, and it still does that. 1.4.1 never did that.

import java.util.TimeZone;
public class jdk142exc {
	public static void main(String[] args) {
		TimeZone tz = TimeZone.getTimeZone("UTC");
		System.out.println(tz);
	}
}
Comment 1 Luc Bourlier CLA 2003-11-19 19:37:53 EST
That looks like a VM problem for me.

By default, the debugger ask the VM to stop on uncaught exception (only). But it
appears that sun VM 1.4.2 does not get the right caught/uncaught status in this
case, and suspend because it thinks this exception is not caught.

You can unset 'suspend on uncaught exception' in window>preferences>java>debug.
Comment 2 Darin Wright CLA 2003-11-19 20:08:46 EST
We had a bug related to this in M4. What build are you using?
Comment 3 quartz quartz CLA 2003-11-20 10:49:55 EST
i am using 3.0 i20030910.
Comment 4 Darin Wright CLA 2003-11-20 11:05:57 EST

*** This bug has been marked as a duplicate of 44759 ***
Comment 5 Luc Bourlier CLA 2003-11-20 11:14:18 EST
Created attachment 6885 [details]
jdb debug trace

I can reproduce the proble with I200311192030 on sun 1.4.2 and with jdb from
sun 1.4.2.
Comment 6 Luc Bourlier CLA 2003-11-20 11:16:23 EST
I was too slow ...
I think it's a VM problem, I haven't find anything in Sun bug database.
Comment 7 quartz quartz CLA 2003-11-20 12:41:15 EST
thanks for reporting it to sun. (I assume you had/will because you know much
better than I what is involved during debugging).
Comment 8 Darin Wright CLA 2003-12-01 11:34:51 EST
Luc, please open a Sun bug report, and then close this bug.
Comment 9 Luc Bourlier CLA 2003-12-04 12:34:58 EST
I filled a Sun bug report (Review ID: 228951).
Now waiting that they evaluate my report (that can take 3 weeks).
Comment 10 Luc Bourlier CLA 2003-12-09 10:21:00 EST
The bug report has been accepted by Sun.
http://developer.java.sun.com/developer/bugParade/bugs/4965317.html

Closing this bug.
Comment 11 quartz quartz CLA 2004-01-29 10:38:11 EST
after investigation, Sun says this is not a bug,
http://developer.java.sun.com/developer/bugParade/bugs/4965317.html

I tryed with latest jdk
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

and put back both the suspend on uncaught/caught exception
and eclipse i20040121 still stop for this TimeZone.getTimeZone("UTC") example.
Comment 12 Luc Bourlier CLA 2004-01-29 14:04:04 EST
Marking as wontfix.

There is nothing we can do, it's a limitation of the VM.
In this specific case, it does not get the right caught/uncaught status. We have
to believe what the VM says, because we have no better way to get this information.

I knew this was a common VM problem, but not that the spec says the information
can be wrong.
There are more information about this problem in the javadoc of
ExceptionEvent#catchLocation().
http://java.sun.com/j2se/1.4.2/docs/guide/jpda/jdi/com/sun/jdi/event/ExceptionEvent.html#catchLocation()
Comment 13 quartz quartz CLA 2004-01-29 22:35:39 EST
well, somebody has to fix something...
can you rephrase the bug to sun so that they understand that the information is
wrong, as you say? Because you definitely found a bug. You just need to
communicate it in a way that sun will understand and acknoledge it.

maybe if you take the "clarify spec" approach, they will jump on it, then at the
next iteration, they will be forced to fix the bug...!

Thanks.
Comment 14 quartz quartz CLA 2004-01-29 22:46:48 EST
or better, request-for-enhancements.

Seams to me that the jdi, aware of any native stackframe, could fire the
exception event with an additionnal flag telling if the exception is under a
native call.

That way, in eclipse, you could offer an option like "ignore uncaught exception
behind native calls".

simple enough.
good luck. I stay tuned.
Comment 15 quartz quartz CLA 2004-01-30 08:46:31 EST
Sorry, you were wrong saying that you couldn't do anything.
You can do something:

walk up StackFrames in the BreakPointEvent.thread().frames() list:
if StackFrame.location().method().isNative()
then ignore event.

I knew nothing about jdi and it took me ~30 minutes to find that.

(Pretty cool stuff that jdi...
E.Gamma: is there a junit fixture that does code-coverage tests?)
Comment 16 quartz quartz CLA 2004-02-14 15:21:40 EST
Created attachment 7925 [details]
simple jdi code to show and solve the problem

this show how we can simply detect the uncaught exceptions that are behind
native methods and decide if we want to resume or not (the 2 commented lines in
the jdi handler: if(behindNative) tr.resume())
Comment 17 quartz quartz CLA 2004-02-14 15:25:58 EST
reminder: we still can't debug a 1.4.2 jvm
without disabling the "suspend on uncaught", which is overkill and does not help
developpers to track the cause of an uncaught exception because it doesn't
suspend the thread.
Comment 18 Luc Bourlier CLA 2004-02-14 16:43:02 EST
I filed a feature request for the more general problem (bug 52063).
Closing this bug.

quarts12h: FYI, this is the only instance of this problem that had been reported
to us.
Comment 19 Luc Bourlier CLA 2004-02-28 14:41:20 EST
*** Bug 53346 has been marked as a duplicate of this bug. ***