Top Description Inners Fields Constructors Methods
org.graalvm.jniutils

public final Class JNICalls

extends Object
Class Inheritance
Static Imports
org.graalvm.jniutils.JNIExceptionWrapper.wrapAndThrowPendingJNIException, .JNIUtil.createString, .JNIUtil.trace, .JNIUtil.tracingAt

Support for calling into HotSpot using JNI. In addition to calling a method using JNI, the JNICalls also perform JNI call tracing and exception handling. All JNI calls into HotSpot must use this support to correctly merge HotSpot and native image stack traces.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static @interface
JNICalls.JNICall

Marker annotation for the helper methods for calling a method in HotSpot.

public static interface
JNICalls.JNIMethod

Represents a JNI method.

Field Summary

Modifier and TypeField and Description
private final JNIExceptionWrapper.ExceptionHandler
private static final JNICalls
private static final ThreadLocal<Boolean>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
callBoolean(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning boolean.

public byte
callByte(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning byte.

public char
callChar(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning char.

public double
callDouble(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning double.

public float
callFloat(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning float.

public int
callInt(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning int.

public <R extends JNI.JObject> R
callJObject(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning Object.

public long
callLong(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning long.

public <R extends JNI.JObject> R
callNewObject(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod constructor, JNI.JValue args)

Creates a new object instance using a given constructor.

public short
callShort(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning short.

public boolean
callStaticBoolean(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning boolean.

public int
callStaticInt(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning int.

public <R extends JNI.JObject> R
callStaticJObject(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning Object.

public long
callStaticLong(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning long.

public void
callStaticVoid(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static void method.

public void
callVoid(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a void method.

public static JNICalls
createWithExceptionHandler(JNIExceptionWrapper.ExceptionHandler handler)

Creates a new JNICalls instance with a custom exception handler.

public static JNICalls
getDefault()

Returns a JNICalls instance with a default exception handler.

private static String
private static void
private static void
traceCall(JNI.JNIEnv env, JNI.JObject receiver, JNICalls.JNIMethod method)

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exceptionHandlerback to summary
private final JNIExceptionWrapper.ExceptionHandler exceptionHandler
INSTANCEback to summary
private static final JNICalls INSTANCE
inTraceback to summary
private static final ThreadLocal<Boolean> inTrace

Constructor Detail

JNICallsback to summary
private JNICalls(JNIExceptionWrapper.ExceptionHandler exceptionHandler)

Method Detail

callBooleanback to summary
public boolean callBoolean(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning boolean.

Annotations
@JNICall
callByteback to summary
public byte callByte(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning byte.

Annotations
@JNICall
callCharback to summary
public char callChar(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning char.

Annotations
@JNICall
callDoubleback to summary
public double callDouble(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning double.

Annotations
@JNICall
callFloatback to summary
public float callFloat(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning float.

Annotations
@JNICall
callIntback to summary
public int callInt(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning int.

Annotations
@JNICall
callJObjectback to summary
public <R extends JNI.JObject> R callJObject(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning Object.

Annotations
@JNICall
@SuppressWarnings:unchecked
callLongback to summary
public long callLong(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning long.

Annotations
@JNICall
callNewObjectback to summary
public <R extends JNI.JObject> R callNewObject(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod constructor, JNI.JValue args)

Creates a new object instance using a given constructor.

Annotations
@JNICall
@SuppressWarnings:unchecked
callShortback to summary
public short callShort(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a method returning short.

Annotations
@JNICall
callStaticBooleanback to summary
public boolean callStaticBoolean(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning boolean.

Annotations
@JNICall
callStaticIntback to summary
public int callStaticInt(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning int.

Annotations
@JNICall
callStaticJObjectback to summary
public <R extends JNI.JObject> R callStaticJObject(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning Object.

Annotations
@SuppressWarnings:unchecked
@JNICall
callStaticLongback to summary
public long callStaticLong(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static method returning long.

Annotations
@JNICall
callStaticVoidback to summary
public void callStaticVoid(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a static void method.

Annotations
@JNICall
callVoidback to summary
public void callVoid(JNI.JNIEnv env, JNI.JObject object, JNICalls.JNIMethod method, JNI.JValue args)

Performs a JNI call of a void method.

Annotations
@JNICall
createWithExceptionHandlerback to summary
public static JNICalls createWithExceptionHandler(JNIExceptionWrapper.ExceptionHandler handler)

Creates a new JNICalls instance with a custom exception handler. The given exception handler is used to handle pending JNI exceptions.

getDefaultback to summary
public static JNICalls getDefault()

Returns a JNICalls instance with a default exception handler. The default exception handler rethrows any pending JNI exception as a JNIExceptionWrapper.

toSimpleNameback to summary
private static String toSimpleName(String fqn)
traceCallback to summary
private static void traceCall(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method)
traceCallback to summary
private static void traceCall(JNI.JNIEnv env, JNI.JObject receiver, JNICalls.JNIMethod method)
traceCallImplback to summary
private static void traceCallImpl(JNI.JNIEnv env, JNI.JClass clazz, JNICalls.JNIMethod method)
org.graalvm.jniutils back to summary

pack-priv @Interface JNICalls.JNICall

extends Annotation
Annotations
@Retention:RUNTIME
@Target:METHOD

Marker annotation for the helper methods for calling a method in HotSpot.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString
org.graalvm.jniutils back to summary

public Interface JNICalls.JNIMethod

Known Direct Implementers
org.graalvm.jniutils.JNIExceptionWrapper.JNIMethodResolver

Represents a JNI method.

Method Summary

Modifier and TypeMethod and Description
public static JNICalls.JNIMethod
findMethod(JNI.JNIEnv env, JNI.JClass clazz, boolean staticMethod, String methodName, String methodSignature)

Finds a JNIMethod in the given clazz with the given name and signature.

public static JNICalls.JNIMethod
findMethod(JNI.JNIEnv env, JNI.JClass clazz, boolean staticMethod, boolean required, String methodName, String methodSignature)

Finds a JNIMethod in given clazz with given name and signature.

public String
getDisplayName()

Returns a method display name used for logging.

public JNI.JMethodID
getJMethodID()

Returns a method JNI JMethodID.

Method Detail

findMethodback to summary
public static JNICalls.JNIMethod findMethod(JNI.JNIEnv env, JNI.JClass clazz, boolean staticMethod, String methodName, String methodSignature)

Finds a JNIMethod in the given clazz with the given name and signature. If such a method does not exist throws JNIExceptionWrapper wrapping a NoSuchMethodError.

findMethodback to summary
public static JNICalls.JNIMethod findMethod(JNI.JNIEnv env, JNI.JClass clazz, boolean staticMethod, boolean required, String methodName, String methodSignature)

Finds a JNIMethod in given clazz with given name and signature. If such a method does not exist and required is true, it throws JNIExceptionWrapper wrapping a NoSuchMethodError. If required is false it clears the pending JNI exception and returns a C NULL pointer.

getDisplayNameback to summary
public String getDisplayName()

Returns a method display name used for logging.

getJMethodIDback to summary
public JNI.JMethodID getJMethodID()

Returns a method JNI JMethodID.