CEntryPoint
@Retention(RUNTIME)
@Target({METHOD})
public @interface CEntryPointAnnotates a method that is a VM entry point. Such a method must be declared static, and is made accessible so that it can be called as a C function using the native ABI.
An execution context must be passed as an IsolateThread that is specific to the current thread. This pointer can be obtained via CurrentIsolate.getCurrentThread(). When there is more than one parameter of IsolateThread, exactly one of the parameters must be annotated with IsolateThreadContext.
Exceptions cannot be thrown to the caller and must be explicitly caught in the entry point method. Any uncaught exception causes the termination of the process after it is printed.
No object types are permitted for parameters or return types; only primitive Java values, word values, and enum values are allowed. Enum values are automatically converted from integer constants to Java enum object constants. The enum class must have a CEnum annotation. When enum values are passed as parameters, the enum class must have a method with a CEnumLookup annotation. For enum return types, the enum class must have a method that is annotated with CEnumValue.
Elements6
String name()
String[] documentation()
documentation
since 19.0String[] documentation() default {""}Method documentation to be included in the header file, as an array of lines.
Returns
String[]- No description.
Default: {""}
Class<? extends CEntryPoint.ExceptionHandler> exceptionHandler()
exceptionHandler
since 19.0Class< ? extends CEntryPoint.ExceptionHandler> exceptionHandler() default org.graalvm.nativeimage.c.function.CEntryPoint.FatalExceptionHandler.classProvides an exception handler for all exceptions that are not handled explicitly by the entry point method. Java exceptions cannot be passed back to C code. If this property is not set, any uncaught exception is treated as a fatal error.
The provided class must have exactly one declared method (the exception handler method). The method must be static, have one parameter of type Throwable or Object, and must have a return type that is assignable to the return type of the annotated entry point method. That exception handler method is invoked when an exception reaches the entry point, and the exception is passed as the argument. The return value of the exception handler method is then the return value of the entry point, i.e., passed back to the C code.
Returns
Class<? extends CEntryPoint.ExceptionHandler> - No description.
Default: org.graalvm.nativeimage.c.function.CEntryPoint.FatalExceptionHandler.class
CEntryPoint.Builtin builtin()
builtin
since 19.0CEntryPoint.Builtin builtin() default NO_BUILTINSpecifies that the annotated entry point method is an alias for a built-in function as provided by the C API. Such aliases may have extra arguments which are ignored and can be used to adhere to specific external conventions. The annotated method must be declared native and as such, cannot have its own code body. Refer to the C API for descriptions of the built-ins, and to the individual built-ins for their requirements to the annotated method's signature.
Returns
CEntryPoint.Builtin- No description.
Default: NO_BUILTIN
Class<? extends BooleanSupplier> include()
include
since 22.0Class< ? extends BooleanSupplier> include() default org.graalvm.nativeimage.c.function.CEntryPoint.AlwaysIncluded.classIf the supplier returns true, this entry point is added automatically when building a shared library. This means the method is a root method for compilation, and everything reachable from it is compiled too. The provided class must have a nullary constructor, which is used to instantiate the class. Then the supplier function is called on the newly instantiated instance.
Returns
Class<? extends BooleanSupplier> - No description.
Default: org.graalvm.nativeimage.c.function.CEntryPoint.AlwaysIncluded.class
CEntryPoint.Publish publishAs()
publishAs
since 22.0CEntryPoint.Publish publishAs() default SymbolAndHeaderWhether the entry point is part of the symbols and header files produced by Native Image.
Returns
CEntryPoint.Publish- No description.
Default: SymbolAndHeader
Nested types
public final class .AlwaysIncludedA
BooleanSupplierthat always returnstrue.public enum .BuiltinThe built-in methods which can be aliased.
public interface .ExceptionHandlerMarker interface for all
exception handlerclasses.public final class .FatalExceptionHandlerSpecial placeholder value for
exceptionHandler()to print the caught exception and treat it as afatal error.public @interface .IsolateContextDesignates an
Isolateparameter to use as the execution context.public @interface .IsolateThreadContextDesignates an
IsolateThreadparameter to use as the execution context.public final class .NotIncludedAutomaticallyA
BooleanSupplierthat always returnsfalse.public enum .PublishNo description.