JDK-8351569 : [lworld] Revisit atomic access modes in flat var handles
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: repo-valhalla
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-03-10
  • Updated: 2025-05-19
  • Resolved: 2025-03-24
Related Reports
Causes :  
Causes :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Flat fields cannot, in general support atomic access modes such as `compareAndExchage`. The same goes for array element var handles, as performing an atomic access operation on an element of a flattened array cannot, in general, be supported.

The current implementation supports these operations using locking. Not only this is inefficient, but atomicity guarantees can only be provided as long as all actors access the storage through the var handle (and its associated lock). That is, if thread A performs an atomic access using a var handle, but thread B just performs a plain access on the same variable, atomicity is lost.

Conservatively, we should:
* make sure that var handles pointing to flat fields only support plain modes
* non-plain access modes on array element var handles reject flat array parameters
Comments
A pull request was submitted for review. Branch: lworld URL: https://git.openjdk.org/valhalla/pull/1402 Date: 2025-03-19 18:31:27 +0000
20-03-2025