Philip Grove wrote:In all my years of programming Java I have never seen this happen before, so a quick (I hope) follow up question.
I understand fully well that by catching Exception we have entered the realm of exception antipatterns, but why does it squash the stack trace?
NullPointerException is a subclass of RuntimeException which in turn is a subclass of Exception,
so the NullPointerException is caught and long as nobody does anything to e other than read from it the information should remain unchanged.
Philip Grove wrote:The stack trace gets printed in both the email and the log entry and is just "NullPointerException" is both cases
So it is not lost because nobody prints it, it appear to be lost because nobody sets it or somebody destroys it.
Jeff Verdegan wrote:
Then that's not a stack trace. That's just the exception's toString(). Did you study my code and its output?
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jelle Klap wrote:This maybe related to a JIT compiler optimization that recompiles a method it throws a certain exception a couple of times. After recompilation the compiler can throw a pre-allocated exception, which naturally doesn't have the correct, or rahter any, strack trace.
Though this was a "bug" in the Hotspot server JVM, you seem to be using an Java 6 compatible IcedTea JVM. So I'm not sure if the same workaround applies to it, but for the hotspot VM there's a flag -XX:-OmitStackTraceInFastThrow that turns of the JIT optimization.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Philip Grove wrote:I know for certain that that is the result of calling printStackTrace on the instance of Exception.
I read your code, but studying it is pointless as it tells me nothing I didn't already know. I do know exception handling a everything that comes with it
There is no "i" in denial. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|