-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
minimal
-
-
Java API
-
SE
Summary
The layout constants ValueLayout.JAVA_LONG
and ValueLayout.JAVA_DOUBLE
assume 8-byte alignment even on 32-bit platform, which is incorrect.
Problem
All layout constants in ValueLayout
assume an alignment that is the same as their size. This holds for constants such as ValueLayout.JAVA_LONG
and ValueLayout.JAVA_DOUBLE
, which assume 8-byte alignment. This assumption is incorrect on 32-bit platform, as long[]</code> and <code class="prettyprint" >double[]
arrays can only guarantee that their elements will be 4-byte aligned.
This also creates issues when using layouts such as JAVA_LONG
and JAVA_DOUBLE
to interact with the Linker
on 32-bit platforms: C types in such platforms are typically only 4-byte aligned, which means the linker would detect an alignment mismatch.
Solution
The solution is to tweak the layout constants such as JAVA_LONG
and JAVA_DOUBLE
so that they honestly reflect whatever alignment constraint can be provided by a particular platform. A good way to specify these constants is to define their alignment to be the same as the size of the ADDRESS
constant (as that is also platform-dependent).
Specification
A summary of the required changes is attached to this CSR (see 8308248_v1.zip). Links are also included below:
Javadoc: https://cr.openjdk.org/~mcimadamore/jdk/8308248/8308248/v1/javadoc/java.base/module-summary.html
Specdiff: https://cr.openjdk.org/~mcimadamore/jdk/8308248/8308248/v1/specdiff_out/overview-summary.html
- csr of
-
JDK-8308248 Revisit alignment of layout constants on 32-bit platforms
-
- Closed
-