Annotation Interface CPointerTo


@Retention(RUNTIME) @Target(TYPE) public @interface CPointerTo
Denotes Java interface that imports a C pointer type. The interface must extend PointerBase, i.e., it is a word type. There is never a Java class that implements the interface.

If the method has a non-void return type that is not the annotated interface, it is a read-method of the pointer. Calls of the method are replaced with a memory read. The possible signatures are ValueType read([IntType index], [LocationIdentity locationIdentity]);

If the method has the return type void, it is a write-method of the pointer. Calls of the method are replaced with a memory write. The possible signatures are void write([IntType index], ValueType value, [LocationIdentity locationIdentity]);

If the return type of the method is the annotated interface, it is an address computation for an array access. Calls of the method are replaced with address arithmetic. The possible signatures are PointerType addressOf(IntType index);

The receiver is the pointer that is accessed, i.e., the base address of the memory access.

The ValueType must be the Java-equivalent of the C type used in the pointer definition.

The optional parameter index (always the first parameter when it is present) denotes an index, i.e., the receiver is treated as an array of the pointers. The type must be a primitive integer type or a word type. Address arithmetic is used to scale the index with the size of the value type.

The optional parameter locationIdentity specifies the LocationIdentity to be used for the memory access. Two memory accesses with two different location identities are guaranteed to not alias. The parameter cannot be used together with the UniqueLocationIdentity annotation, which is another way of providing a location identity for the memory access.

Since:
19.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The value type, as C type name.
    Class<? extends WordBase>
    The value type, as a reference to a Java interface that is either annotated with CStruct or CPointerTo.
  • Element Details

    • value

      Class<? extends WordBase> value
      The value type, as a reference to a Java interface that is either annotated with CStruct or CPointerTo.

      Exactly one of the properties value() and nameOfCType() must be specified.

      Since:
      19.0
      Default:
      org.graalvm.word.WordBase.class
    • nameOfCType

      String nameOfCType
      The value type, as C type name.

      Exactly one of the properties value() and nameOfCType() must be specified.

      Since:
      19.0
      Default:
      ""