Skip to content

Instantly share code, notes, and snippets.

View mcimadamore's full-sized avatar

Maurizio Cimadamore mcimadamore

View GitHub Profile
@mcimadamore
mcimadamore / Test.java
Created June 3, 2022 21:49
Example of struct access with layouts and heap segments
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.SequenceLayout;
import java.lang.foreign.ValueLayout;
import java.lang.invoke.VarHandle;
public class Test {
static final ValueLayout.OfChar JAVA_CHAR_UNALIGNED = ValueLayout.JAVA_CHAR.withBitAlignment(8);
static final ValueLayout.OfInt JAVA_INT_UNALIGNED = ValueLayout.JAVA_INT.withBitAlignment(8);