JDK-8046503 : Ability to reset OmitStackTraceInFastThrow counter
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • Submitted: 2013-03-04
  • Updated: 2021-09-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
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.

For production environments, it is desirable to keep this optimization on, but in the case that exceptions start getting thrown, it becomes extremely difficult to debug the system without stack traces.  I propose the implementation of some means of resetting the counter, so that stack traces return without having to restart the system, perhaps via JMX.

JUSTIFICATION :
Currently, one can disable the performance optimization all together using -XX:-OmitStackTraceInFastThrow but in production environments, this optimization could be too valuable to completely forgo.

If an exception starts occurring, and some debugging is needed, if one were to restart the system and use the -XX:-OmitStackTraceInFastThrow flag, there are many circumstances where the exception will no longer be reproducible.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If the JVM is running, and starts throwing exceptions without stack traces, the user should be able to some how trigger the JVM to once again return stack traces.    Even if this is just momentary, such that the stack trace will again have the potential to be optimized away, the ability to reset the stack trace production would be very beneficial.  I have no concrete suggestion for the form of the trigger, but JMX would be convenient.
ACTUAL -
There is no current way to reset stack traces without restarting the JVM.
Comments
Maybe a better solution would be to make this a CompileCommand option such that it can be selectively enabled for really performance critical methods?
16-04-2021

Turning off OmitStackTraceInFastThrow at runtime is not enough. The affected methods would also need to be recompiled and StackTraceInThrowable needs to be enabled as well. This is a Will-Not-Fix candidate.
25-01-2017

This is a compiler flag, giving this to the compiler to decide if this flag can be changed during execution
16-06-2014