JDK-8273392 : Improve usability of stack-less exceptions due to -XX:+OmitStackTraceInFastThrow
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 18,19
  • Priority: P4
  • Status: In Progress
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2021-09-06
  • Updated: 2022-06-08
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 :  
Relates :  
Relates :  
Relates :  
Description
If running with -XX:+OmitStackTraceInFastThrow (which is the default) C2 will optimize certain "hot" implicit exceptions (i.e. AIOOBE, NullPointerExceptions,..) and replace them by a static, pre-allocated exception without any stacktrace.

However, we can actually do better. Instead of using a single, pre-allocated exception object for all method we can let the compiler allocate specific exceptions for each method and fill them with at least one stack frame with the method /line-number information of the currently compiled method. If the method in question is being inlined, we can add stackframes for all callers up to the inlining depth of the method in question.

This optimization comes at no run-time costs because all the extra work will be done at compile time.
Comments
Moving to JDK 19 as the fork is done today.
09-12-2021