JDK-8325944 : Release Note: Relax Alignment of Array Elements
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2024-02-15
  • Updated: 2024-08-01
  • Resolved: 2024-02-15
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 23
23Resolved
Description
Array element bases are no longer unconditionally aligned to eight bytes. Instead, they are now aligned to their element type size. This improves the footprint in some JVM modes. As Java array element alignment is not exposed to users, there is no impact on regular Java code that accesses individual elements.

There are implications for bulk access methods. Unsafe accesses to arrays could now be unaligned. For example, `Unsafe.getLong(byteArray, BYTE_ARRAY_BASE_OFFSET + 0)` is not guaranteed to work on platforms that do not allow unaligned accesses. A workaround is the `Unsafe.{get, put}Unaligned*` family of methods. The `ByteBuffer` and `VarHandle` APIs that allow views of `byte[]` are updated to reflect this change (JDK-8318966). Arrays that are acquired via `GetPrimitiveArrayCritical` should not be operated upon under the assumption of a particular array base alignment.