Class CConstant.ValueAccess

java.lang.Object
org.graalvm.nativeimage.c.constant.CConstant.ValueAccess
Enclosing class:
CConstant

public static final class CConstant.ValueAccess extends Object
Allows access to the value of a CConstant during image generation.
Since:
19.0
  • Method Details

    • get

      public static <T> T get(Class<?> declaringClass, String methodName, Class<T> returnType)
      Returns the value of a CConstant, i.e., the same value that calling the annotated method would return.

      This method is useful during native image generation, when the annotated method cannot be called.

      Parameters:
      declaringClass - The class that contains the method.
      methodName - The name of the method annotated with CConstant.
      returnType - The desired type of the returned value. For integer-kind constants, the supported types are Boolean, Byte, Short, Character, Integer, and Long. For floating point constants, the supported types are Double and Float. For string constants, the only supported types are String and byte[].
      Returns:
      The value of the C constant.
      Since:
      19.0
    • get

      public static <T> T get(Enum<?> cEnum, String methodName)
      Returns the value of a CEnum, i.e., the same value that calling the method annotated with CEnumValue would return.

      This method is useful during native image generation, when the annotated method cannot be called.

      Parameters:
      cEnum - The enum value for which the C value should be returned. The enum type must be annotated with CEnum.
      methodName - The name of the method annotated with CEnumValue.
      Returns:
      The value of the C constant.
      Since:
      24.2