use of com.oracle.svm.jni.nativeapi.JNIObjectHandle in project graal by oracle.
the class JNIFunctions method NewGlobalRef.
/*
* jobject NewGlobalRef(JNIEnv *env, jobject obj);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnNullHandle.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static JNIObjectHandle NewGlobalRef(JNIEnvironment env, JNIObjectHandle handle) {
JNIObjectHandle result = JNIObjectHandles.nullHandle();
Object obj = JNIObjectHandles.getObject(handle);
if (obj != null) {
result = (JNIObjectHandle) JNIGlobalHandles.singleton().create(obj);
}
return result;
}
use of com.oracle.svm.jni.nativeapi.JNIObjectHandle in project graal by oracle.
the class JNIFunctions method NewWeakGlobalRef.
/*
* jweak NewWeakGlobalRef(JNIEnv *env, jobject obj);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnNullHandle.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static JNIObjectHandle NewWeakGlobalRef(JNIEnvironment env, JNIObjectHandle handle) {
JNIObjectHandle result = JNIObjectHandles.nullHandle();
Object obj = JNIObjectHandles.getObject(handle);
if (obj != null) {
result = (JNIObjectHandle) JNIGlobalHandles.singleton().createWeak(obj);
}
return result;
}
use of com.oracle.svm.jni.nativeapi.JNIObjectHandle in project graal by oracle.
the class JNIFunctions method ThrowNew.
/*
* jint ThrowNew(JNIEnv *env, jclass clazz, const char *message);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerVoid.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void ThrowNew(JNIEnvironment env, JNIObjectHandle clazzHandle, CCharPointer message) throws Throwable {
Class<?> clazz = JNIObjectHandles.getObject(clazzHandle);
JNIMethodId ctor = JNIReflectionDictionary.singleton().getMethodID(clazz, "<init>", "(Ljava/lang/String;)V", false);
JNIObjectHandle messageHandle = NewStringUTF(env, message);
NewObjectWithObjectArgFunctionPointer newObject = (NewObjectWithObjectArgFunctionPointer) env.getFunctions().getNewObject();
JNIObjectHandle exception = newObject.invoke(env, clazzHandle, ctor, messageHandle);
throw (Throwable) JNIObjectHandles.getObject(exception);
}
Aggregations