use of com.oracle.svm.jni.access.JNINativeLinkage in project graal by oracle.
the class JNIFunctions method UnregisterNatives.
/*
* jint UnregisterNatives(JNIEnv *env, jclass clazz);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnJniErr.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static int UnregisterNatives(JNIEnvironment env, JNIObjectHandle hclazz) {
Class<?> clazz = JNIObjectHandles.getObject(hclazz);
String internalName = MetaUtil.toInternalName(clazz.getName());
for (JNINativeLinkage linkage : JNIReflectionDictionary.singleton().getLinkages(internalName)) {
linkage.unsetEntryPoint();
}
return JNIErrors.JNI_OK();
}
use of com.oracle.svm.jni.access.JNINativeLinkage in project graal by oracle.
the class JNIFunctions method RegisterNatives.
/*
* jint RegisterNatives(JNIEnv *env, jclass clazz, const JNINativeMethod *methods, jint
* nMethods);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnJniErr.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static int RegisterNatives(JNIEnvironment env, JNIObjectHandle hclazz, JNINativeMethod methods, int nmethods) {
Class<?> clazz = JNIObjectHandles.getObject(hclazz);
Pointer p = (Pointer) methods;
for (int i = 0; i < nmethods; i++) {
JNINativeMethod entry = (JNINativeMethod) p;
String name = CTypeConversion.toJavaString(entry.name());
String signature = CTypeConversion.toJavaString(entry.signature());
CFunctionPointer fnPtr = entry.fnPtr();
String declaringClass = MetaUtil.toInternalName(clazz.getName());
JNINativeLinkage linkage = JNIReflectionDictionary.singleton().getLinkage(declaringClass, name, signature);
if (linkage != null) {
linkage.setEntryPoint(fnPtr);
} else {
return JNIErrors.JNI_ERR();
}
p = p.add(SizeOf.get(JNINativeMethod.class));
}
return JNIErrors.JNI_OK();
}
Aggregations