JDK-8297784 : Optimize @Stable field for Method.isCallerSensitive
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 19,20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-11-29
  • Updated: 2022-12-05
  • Resolved: 2022-12-02
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 20
20 masterFixed
Related Reports
Relates :  
Description
JDK-8271820 introduced the `@Stable private Boolean callerSensitive;` cache in `Method`. That field is essentially a tri-state `Boolean` that relies on its `null` value to serve as "not initialized" value for `@Stable`.

This works well when the holder `Method` instance is constant: JIT compilers fold `@Stable` well. But if such folding fails, we always dereference the full-blown reference to "boxed" `Boolean` from the field on every access. We can instead do a more lean tri-state primitive field to improve that non-optimized case without sacrificing optimized case.
Comments
Changeset: 9bbcb546 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2022-12-02 07:29:27 +0000 URL: https://git.openjdk.org/jdk/commit/9bbcb546c86b40ae23d46e12a1a03aae7a7a6182
02-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11422 Date: 2022-11-29 19:39:02 +0000
29-11-2022