2007/10/15, Alexey Varlamov <[EMAIL PROTECTED]>: > 2007/10/14, Gregory Shimansky <[EMAIL PROTECTED]>: > > Oliver Deakin wrote: > > > Hi all, > > > > > > A little while back there was a thread called "[drlvm] Should the > > > launcher print uncaught exceptions?" [1] where we discussed the fact > > > that running a test case like [2] did not print a stack trace with the > > > Harmony launcher. As part of this discussion, HARMONY-1819 was raised > > > and the line "(*jvm)->DetachCurrentThread(jvm)" was added to the > > > launcher main.c in repo revision r464443. > > > > > > HARMONY-3713 was later raised pointing out that calling > > > DetachCurrentThread() to detach the main thread was contrary to the spec > > > [3], and the line was removed from main.c. However, I have just noticed > > > that if you run [2] on the current J9 VME (and, in fact, on the RI with > > > a simple launcher) you do not get any stack trace printed, and I imagine > > > this has been the case since the commit of HARMONY-3713. > > > > > > The RI has a bug [4], contrary to the spec [3], which requires > > > DetachCurrentThread() to be called by the invoking launcher if you wish > > > to see the stack trace of an uncaught exception. It appears that J9 has > > > matched this bug, probably so no unexpected trace is printed in > > > launchers programmed against the RI. > > > > > > So currently running Harmony classlib with the J9 VME will not result in > > > any stack trace being printed for uncaught exceptions, which makes > > > debugging issues where that occurs more troublesome. Id like to propose > > > that the DetachCurrentThread() line be readded to main.c (i.e. the > > > opposite of the patch for HARMONY-3713), perhaps with a comment to show > > > that this is to match the behaviour of the RI rather than the spec. > > > > > > Any objections? > > > > I wonder if simply adding > > > > if ((*env)->ExceptionCheck(env)) > > (*env)->ExceptionDescribe(env); > > > > is enough to print out stack trace in the main thread without violating > > the spec. > > > > The bug of RI [4] (fixed in 1.5) being referred by Oliver is a bit > wider than just printing out the stack trace. Synopsis reads: > "(thread) setUncaughtExceptionHandler() doesn't work on main thread ". > I believe this is really strong argument to use DetachCurrentThread > and be compatible with RI rather than spec (which should be fixed and > will be someday ;)
FYI, spec is indeed fixed in 1.6 : http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/invocation.html#wp16553 > Moreover, I suggest to add a regression test for this issue (like the > one in [4]) so the decision would stay locked in. > > [4] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4992454 > -- > Alexey > > > > > -- > > Gregory > > > > >
