Clojure/Java: Prevent Exceptions With "trace missing"
Join the DZone community and get the full member experience.Join For Free
The other day I got this little helpful exception from Clojure:
(cond (>= nil 1) :unreachable) ;=> NullPointerException [trace missing]
- no line number or anything to troubleshoot it.
It turns out it is not Clojure’s failure but a HotSpot optimization that can apply to
ClassCastException. The remedy is to run the JVM with
From Oralce JDK release notes:
The compiler in the server VM now provides correct stack backtraces for all “cold” built-in exceptions. For performance purposes, when such an exception is thrown a few times, the method may be recompiled. After recompilation, the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace. To disable completely the use of preallocated exceptions, use this new flag:
Many thanks to Ivan Kozik for the info!
Published at DZone with permission of Jakub Holý, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.