Annotation Interface CFunction
native
method that calls directly from Java to C, without following the JNI
protocol. This means that there are no artificial additional parameters such as the JNI
environment passed, and no marshaling or processing of arguments (such as creating handles for
objects) is performed. If the method is non-static, the receiver will be ignored.
Parameter types and return types must not be Java reference types, only
primitive Java types, word types and
CEnum
types are allowed. The representation of passed primitive values matches exactly
how they are specified in the Java language, for example, int
as a 32-bit signed integer
or char
as a 16-bit unsigned integer. boolean
is specified as a single byte that
corresponds to true
if non-zero, and to false
if zero. If a Word value is passed
that points to a Java object, no guarantees are taken regarding its integrity as a pointer.
The class containing the annotated method must be annotated with CContext
.
Note that this annotation must not be used for native functions that use variadic arguments (varargs) because varargs calling conventions are not supported and even a declaration with a specific non-varargs signature can be incompatible with vararg target functions on some platforms.
- Since:
- 19.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Describes the thread state transition performed when the C function is invoked. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe Java-to-C thread transition code used when calling the function.The symbol name to use to link this method.
-
Element Details
-
value
String valueThe symbol name to use to link this method. If no value is specified, the name of the method (without name mangling or a class name prefix) is used.- Since:
- 19.0
- Default:
""
-
transition
CFunction.Transition transitionThe Java-to-C thread transition code used when calling the function.- Since:
- 19.0
- Default:
TO_NATIVE
-