Top Description Fields Constructors Methods
org.graalvm.jniutils

public final Class JNIUtil

extends Object
Class Inheritance
Static Imports
org.graalvm.jniutils.JNI.JNI_OK, .JNI.JNI_VERSION_10, org.graalvm.nativeimage.c.type.CTypeConversion.toCString, org.graalvm.word.WordFactory.nullPointer

Helpers for calling JNI functions.

Field Summary

Modifier and TypeField and Description
private static final int
private static final String[]
private static final String[]
private static final String[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JBooleanArray src, int srcPos, boolean[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, boolean[] src, int srcPos, JNI.JBooleanArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JByteArray src, int srcPos, byte[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, byte[] src, int srcPos, JNI.JByteArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JCharArray src, int srcPos, char[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, char[] src, int srcPos, JNI.JCharArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JShortArray src, int srcPos, short[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, short[] src, int srcPos, JNI.JShortArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JIntArray src, int srcPos, int[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, int[] src, int srcPos, JNI.JIntArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JLongArray src, int srcPos, long[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, long[] src, int srcPos, JNI.JLongArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JFloatArray src, int srcPos, float[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, float[] src, int srcPos, JNI.JFloatArray dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, JNI.JDoubleArray src, int srcPos, double[] dest, int destPos, int length)

public static void
arrayCopy(JNI.JNIEnv jniEnv, double[] src, int srcPos, JNI.JDoubleArray dest, int destPos, int length)

public static JNI.JNIEnv
public static JNI.JNIEnv

Returns:

the current thread JNIEnv or C NULL pointer in case of error.
attachCurrentThread
(JNI.JavaVM
the JavaVM pointer.
vm
,
boolean
if true attaches the thread as a daemon thread.
daemon
,
String
the name of the Java tread or null.
name
,
JNI.JObject
the thread group to add the thread into or C NULL pointer.
threadGroup
)

Attaches the current C thread to a Java Thread.

public static JNI.JNIEnv
public static boolean[]
createArray(JNI.JNIEnv env, JNI.JBooleanArray booleanArray)

public static byte[]
public static char[]
public static short[]
public static int[]
public static long[]
public static float[]
public static double[]
public static JNI.JBooleanArray
createHSArray(JNI.JNIEnv jniEnv, boolean[] a)

public static JNI.JByteArray
createHSArray(JNI.JNIEnv jniEnv, byte[] a)

public static JNI.JCharArray
createHSArray(JNI.JNIEnv jniEnv, char[] a)

public static JNI.JShortArray
createHSArray(JNI.JNIEnv jniEnv, short[] a)

public static JNI.JIntArray
createHSArray(JNI.JNIEnv jniEnv, int[] a)

public static JNI.JLongArray
createHSArray(JNI.JNIEnv jniEnv, long[] a)

public static JNI.JFloatArray
createHSArray(JNI.JNIEnv jniEnv, float[] a)

public static JNI.JDoubleArray
createHSArray(JNI.JNIEnv jniEnv, double[] a)

public static JNI.JObjectArray
createHSArray(JNI.JNIEnv jniEnv, Object[] array, int sourcePosition, int length, String componentTypeBinaryName)

public static JNI.JString
createHSString(JNI.JNIEnv env, String string)

Creates a String in the HotSpot heap from string.

public static String
createString(JNI.JNIEnv env, JNI.JString hsString)

Decodes a string in the HotSpot heap to a local String.

public static JNI.JClass
DefineClass(JNI.JNIEnv env, CCharPointer name, JNI.JObject loader, CCharPointer buf, int bufLen)

public static void
public static void
public static void
public static boolean
public static String
encodeFieldSignature(Class<?> type)

Creates a JVM field signature as specified in the Sections 4.3.2 of the JVM Specification.

public static String
encodeMethodSignature(Class<?> returnType, Class<?>... parameterTypes)

Creates a JVM method signature as specified in the Sections 4.3.3 of the JVM Specification.

private static void
public static boolean
public static void
public static void
public static JNI.JThrowable
public static JNI.JClass
public static JNI.JClass
findClass(JNI.JNIEnv env, String binaryName)

Returns a JClass for given binary name.

public static JNI.JClass
findClass(JNI.JNIEnv
the JNIEnv
env
,
JNI.JObject classLoader, String
the class binary name
binaryName
)

Finds a class in HotSpot heap using a given ClassLoader.

public static JNI.JClass
findClass(JNI.JNIEnv
the JNIEnv
env
,
JNI.JObject
the class loader to find class in or NULL pointer.
classLoader
,
String
the class binary name
binaryName
,
boolean
if true the JNIExceptionWrapper is thrown when the class is not found. If false the NULL pointer is returned when the class is not found.
required
)

Finds a class in HotSpot heap using JNI.

public static JNI.JFieldID
findField(JNI.JNIEnv env, JNI.JClass clazz, boolean staticField, String fieldName, String fieldSignature)

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

pack-priv static JNI.JMethodID
findMethod(JNI.JNIEnv env, JNI.JClass clazz, boolean staticMethod, boolean required, String methodName, String methodSignature)

public static int
public static String
getBinaryName(String fqn)

Converts a fully qualified Java class name from Java source format (e.g. "java.lang.getString") to binary format (e.g. "java/lang/getString".

public static CCharPointer
public static void
GetBooleanArrayRegion(JNI.JNIEnv env, JNI.JBooleanArray array, int offset, int len, CCharPointer buff)

public static CCharPointer
public static void
GetByteArrayRegion(JNI.JNIEnv env, JNI.JByteArray array, int offset, int len, CCharPointer buff)

public static CShortPointer
public static void
GetCharArrayRegion(JNI.JNIEnv env, JNI.JCharArray array, int offset, int len, CShortPointer buff)

public static JNI.JObject
public static VoidPointer
public static CDoublePointer
public static void
GetDoubleArrayRegion(JNI.JNIEnv env, JNI.JDoubleArray array, int offset, int len, CDoublePointer buff)

public static JNI.JNIEnv
pack-priv static String
public static JNI.JFieldID
GetFieldID(JNI.JNIEnv env, JNI.JClass clazz, CCharPointer name, CCharPointer signature)

public static CFloatPointer
public static void
GetFloatArrayRegion(JNI.JNIEnv env, JNI.JFloatArray array, int offset, int len, CFloatPointer buff)

public static CIntPointer
public static void
GetIntArrayRegion(JNI.JNIEnv env, JNI.JIntArray array, int offset, int len, CIntPointer buff)

public static String
getInternalName(String fqn)

Converts a fully qualified Java class name from Java source format (e.g. "java.lang.getString") to internal format (e.g. "Ljava/lang/getString;".

public static int
GetIntField(JNI.JNIEnv env, JNI.JObject object, JNI.JFieldID fieldID)

public static JNI.JavaVM
public static JNI.JObject
getJVMCIClassLoader(JNI.JNIEnv env)

Returns a ClassLoader used to load the compiler classes.

public static CLongPointer
public static void
GetLongArrayRegion(JNI.JNIEnv env, JNI.JLongArray array, int offset, int len, CLongPointer buff)

public static JNI.JMethodID
public static JNI.JObject
public static JNI.JClass
public static CShortPointer
public static void
GetShortArrayRegion(JNI.JNIEnv env, JNI.JShortArray array, int offset, int len, CShortPointer buff)

public static JNI.JFieldID
public static JNI.JMethodID
public static JNI.JObject
public static JNI.JObject
public static boolean
public static boolean
public static JNI.JBooleanArray
NewBooleanArray(JNI.JNIEnv env, int len)

public static JNI.JByteArray
NewByteArray(JNI.JNIEnv env, int len)

public static JNI.JCharArray
NewCharArray(JNI.JNIEnv env, int len)

public static JNI.JDoubleArray
NewDoubleArray(JNI.JNIEnv env, int len)

public static JNI.JFloatArray
NewFloatArray(JNI.JNIEnv env, int len)

public static <T extends JNI.JObject> T

Returns:

JNI global reference for given JObject
NewGlobalRef
(JNI.JNIEnv
the JNIEnv
env
,
T
JObject to create JNI global reference for
ref
,
String
type of the object, used only for tracing to distinguish global references
type
)

Creates a new global reference.

public static JNI.JIntArray
NewIntArray(JNI.JNIEnv env, int len)

public static JNI.JObject
public static JNI.JLongArray
NewLongArray(JNI.JNIEnv env, int len)

public static JNI.JObjectArray
NewObjectArray(JNI.JNIEnv env, int len, JNI.JClass componentClass, JNI.JObject initialElement)

public static JNI.JShortArray
NewShortArray(JNI.JNIEnv env, int len)

public static JNI.JWeak

Returns:

JNI weak global reference for given JObject
NewWeakGlobalRef
(JNI.JNIEnv
the JNIEnv
env
,
JNI.JObject
JObject to create JNI weak global reference for
ref
,
String
type of the object, used only for tracing to distinguish global references
type
)

Creates a new weak global reference.

public static JNI.JObject
public static int
PushLocalFrame(JNI.JNIEnv env, int capacity)

public static void
public static void
public static void
public static void
public static void
public static void
public static void
public static void
public static void
SetBooleanArrayRegion(JNI.JNIEnv env, JNI.JBooleanArray array, int offset, int len, CCharPointer buff)

public static void
SetByteArrayRegion(JNI.JNIEnv env, JNI.JByteArray array, int offset, int len, CCharPointer buff)

public static void
SetCharArrayRegion(JNI.JNIEnv env, JNI.JCharArray array, int offset, int len, CShortPointer buff)

public static void
SetDoubleArrayRegion(JNI.JNIEnv env, JNI.JDoubleArray array, int offset, int len, CDoublePointer buff)

public static void
SetFloatArrayRegion(JNI.JNIEnv env, JNI.JFloatArray array, int offset, int len, CFloatPointer buff)

public static void
SetIntArrayRegion(JNI.JNIEnv env, JNI.JIntArray array, int offset, int len, CIntPointer buff)

public static void
SetLongArrayRegion(JNI.JNIEnv env, JNI.JLongArray array, int offset, int len, CLongPointer buff)

public static void
SetObjectArrayElement(JNI.JNIEnv env, JNI.JObjectArray array, int index, JNI.JObject value)

public static void
SetShortArrayRegion(JNI.JNIEnv env, JNI.JShortArray array, int offset, int len, CShortPointer buff)

public static void
Throw(JNI.JNIEnv env, JNI.JThrowable throwable)

public static void
trace(int level, String format, Object... args)

Emits a trace line composed of format and args if the tracing level equal to or greater than level.

public static void
trace(int level, Throwable throwable)

private static void
traceJNI(String function)

public static boolean
tracingAt(int level)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait