Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Clojure/Java: Prevent Exceptions With "trace missing"

DZone's Guide to

Clojure/Java: Prevent Exceptions With "trace missing"

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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 NullPointerExceptionArithmeticExceptionArrayIndexOutOfBoundsException,ArrayStoreException, and ClassCastException. The remedy is to run the JVM with

-XX:-OmitStackTraceInFastThrow

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: -XX:-OmitStackTraceInFastThrow.

Many thanks to Ivan Kozik for the info!

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Published at DZone with permission of Jakub Holý, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}