JDK-6912065 : final fields in objects need to support inlining optimizations for JSR 292
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-12-19
  • Updated: 2019-11-08
  • Resolved: 2010-01-28
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.
JDK 6 JDK 7 Other
6u21Fixed 7Fixed hs17Fixed
Related Reports
Relates :  
Relates :  
A value in an object field cannot be constant-folded even when the field is marked 'final' and the enclosing object itself can be determined at compile time.  This is because 'final' fields are not enforced by the JVM.

The long term fix for this is to properly optimize the common case of any field which is set in an object constructor and then never changed, not even by reflection or JNI.

This is a performance issue for method handle combinators like MethodHandles.guardWithTest.  They are a hybrid of data structure and function pointer.  As function pointers they need to be inlined and optimized.  As data structures, they are tied together via final fields, which must be foldable at compile time in order to complete the inlining process.

As a stopgap measure, we will instruct the JVM to "trust" final fields in selected (trusted!) packages, notably java.dyn and sun.dyn.  This trust directive will be configurable, so that dynamic language runtimes can be included as necessary.

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/73b22f919c34

SUGGESTED FIX http://cr.openjdk.java.net/~jrose/6912065/webrev.00/