0Pricing
Java Academy · Lesson

Layouts and Structs

Describe native memory layouts.

Describing Native Memory

Native data is rarely a single value. C uses structs, arrays, and unions. FFM models these shapes with memory layouts, letting you read and write structured native memory safely.

The Layout Family

The layout types form a small hierarchy:

  • ValueLayout: a primitive (int, long, double, address)
  • SequenceLayout: a fixed-size array of a layout
  • StructLayout: fields laid out sequentially
  • UnionLayout: overlapping fields

All lessons in this course

  1. Why FFM over JNI
  2. MemorySegment and Arena
  3. Downcall Handles
  4. Layouts and Structs
← Back to Java Academy