Top Description Inners Methods
org.graalvm.nativeimage.c.constant

public @Interface CConstant

extends Annotation
Annotations
@Retention:RUNTIME
@Target:METHOD
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, org.graalvm.nativeimage.ImageSingletons, .Platform, .Platforms, org.graalvm.nativeimage.c.CContext, org.graalvm.nativeimage.impl.CConstantValueSupport

Denotes a method as a C constant value.

Calls to the method are replaced with a compile time constant. The constant value is extracted from the C header file during native image generation.

The class containing the annotated method must be annotated with CContext.

Since
19.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CConstant.ValueAccess

Allows access to the value of a CConstant during image generation.

Method Summary

Modifier and TypeMethod and Description
public String
value()

Specifies the name of the C constant.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public String value()

Specifies the name of the C constant. If no name is provided, the method name is used as the field name. A possible "get" prefix of the method name is removed.

Since
19.0
org.graalvm.nativeimage.c.constant back to summary

public final Class CConstant.ValueAccess

extends Object
Class Inheritance

Allows access to the value of a CConstant during image generation.
Since
19.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T> T

Returns:

The value of the C constant.
get
(Class<?>
The class that contains the method.
declaringClass
,
String
The name of the method annotated with CConstant.
methodName
,
Class<T>
The desired type of the returned value. For integer-kind constants, the supported types are Long, Integer, and Boolean. For floating point constants, the only supported type is Double. For string constants, the only supported type is String.
returnType
)

Returns the value of a CConstant, i.e., the same value that calling the annotated method would return.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ValueAccessback to summary
private ValueAccess()

Method Detail

getback to summary
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:Class<?>

The class that contains the method.

methodName:String

The name of the method annotated with CConstant.

returnType:Class<T>

The desired type of the returned value. For integer-kind constants, the supported types are Long, Integer, and Boolean. For floating point constants, the only supported type is Double. For string constants, the only supported type is String.

Returns:T

The value of the C constant.

Annotations
@Platforms:HOSTED_ONLY
Since
19.0