RFR: 8310053: VarHandle and slice handle derived from layout are lacking alignment check [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jun 14 22:52:59 UTC 2023


On Wed, 14 Jun 2023 22:28:38 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Add missing alignment checks for the alignment constraint of the root layout of a VarHandle created through `MemoryLayout::varHandle` and a MethodHandle `MemoryLayout::sliceHandle`.
>> 
>> Testing: `jdk_foreign` test suite
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
> 
>   formatting

Marked as reviewed by mcimadamore (Reviewer).

src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java line 200:

> 198: 
> 199:         VarHandle handle = Utils.makeSegmentViewVarHandle(valueLayout);
> 200:         handle = MethodHandles.collectCoordinates(handle, 1, offsetHandle());

nice simplification!

test/jdk/java/foreign/TestLayoutPaths.java line 152:

> 150:             String expectedMessage = "Target offset incompatible with alignment constraints: " + struct.byteAlignment();
> 151: 
> 152:             try {

Can assertThrows be used to simplify this pattern?

-------------

PR Review: https://git.openjdk.org/jdk/pull/14475#pullrequestreview-1480416811
PR Review Comment: https://git.openjdk.org/jdk/pull/14475#discussion_r1230245077
PR Review Comment: https://git.openjdk.org/jdk/pull/14475#discussion_r1230246478


More information about the core-libs-dev mailing list