use of com.oracle.svm.jni.access.JNIAccessibleMethodDescriptor in project graal by oracle.
the class JNIFunctions method ToReflectedMethod.
/*
* jobject ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnNullHandle.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static JNIObjectHandle ToReflectedMethod(JNIEnvironment env, JNIObjectHandle classHandle, JNIMethodId methodId, boolean isStatic) {
Executable result = null;
if (JNIAccessFeature.singleton().haveJavaRuntimeReflectionSupport()) {
JNIAccessibleMethod jniMethod = JNIReflectionDictionary.getMethodByID(methodId);
JNIAccessibleMethodDescriptor descriptor = JNIReflectionDictionary.getMethodDescriptor(jniMethod);
if (descriptor != null) {
Class<?> clazz = jniMethod.getDeclaringClass().getClassObject();
if (descriptor.isConstructor()) {
for (Constructor<?> ctor : clazz.getDeclaredConstructors()) {
if (descriptor.equals(JNIAccessibleMethodDescriptor.of(ctor))) {
result = ctor;
break;
}
}
} else {
for (Method method : clazz.getDeclaredMethods()) {
if (descriptor.getName().equals(method.getName())) {
if (descriptor.equals(JNIAccessibleMethodDescriptor.of(method))) {
result = method;
break;
}
}
}
}
}
}
return JNIThreadLocalHandles.get().create(result);
}
use of com.oracle.svm.jni.access.JNIAccessibleMethodDescriptor in project graal by oracle.
the class JNIFunctions method FromReflectedMethod.
/*
* jmethodID FromReflectedMethod(JNIEnv *env, jobject method);
*/
@CEntryPoint
@CEntryPointOptions(prologue = JNIEnvironmentEnterPrologue.class, exceptionHandler = JNIExceptionHandlerReturnNullWord.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static JNIMethodId FromReflectedMethod(JNIEnvironment env, JNIObjectHandle methodHandle) {
JNIMethodId methodId = Word.nullPointer();
if (JNIAccessFeature.singleton().haveJavaRuntimeReflectionSupport()) {
Executable method = JNIObjectHandles.getObject(methodHandle);
if (method != null) {
boolean isStatic = Modifier.isStatic(method.getModifiers());
JNIAccessibleMethodDescriptor descriptor = JNIAccessibleMethodDescriptor.of(method);
methodId = JNIReflectionDictionary.singleton().getMethodID(method.getDeclaringClass(), descriptor, isStatic);
}
}
return methodId;
}
Aggregations