Top Description Methods
org.graalvm.nativeimage.c.struct

public @Interface RawStructure

extends Annotation
Annotations
@Retention:RUNTIME
@Target:TYPE
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, java.util.function.IntUnaryOperator, org.graalvm.word.PointerBase

Denotes Java interface that represents C memory, but without a C struct definition. The interface must extend PointerBase, i.e., it is a word type. There is never a Java class that implements the interface.

Field accesses are done via interface methods that are annotated with RawField. All calls of the interface methods are replaced with the appropriate memory operations.

The layout and size of the structure is inferred from the fields defined with RawField. All fields are aligned according to the field size, i.e., 8-byte types are aligned at 8-byte boundaries. It is currently not possible to influence the layout of fields. However, it is possible to reserve extra space at the end of the structure by specifying a RawStructure#sizeProvider.

To access an array of structs one can define a special addressOf method (see CStruct for more details).

Since
19.0

Method Summary

Modifier and TypeMethod and Description
public Class<? extends IntUnaryOperator>
sizeProvider()

Class of a function that computes the size of the structure.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

sizeProviderback to summary
public Class<? extends IntUnaryOperator> sizeProvider()

Class of a function that computes the size of the structure. The input argument of the function is the size computed based on the layout of the fields of the structure. The returned value must not be smaller than that provided argument.

By default, the size computed based on the layout is used.

The provided class must have a no-argument constructor.

Since
19.2