use of com.oracle.svm.jni.nativeapi.JNINativeMethod 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