use of com.oracle.svm.jni.nativeapi.JNIMethodId in project graal by oracle.
the class JNIReflectionDictionary method getMethodID.
public JNIMethodId getMethodID(Class<?> classObject, JNIAccessibleMethodDescriptor descriptor, boolean isStatic) {
JNIMethodId methodID = WordFactory.nullPointer();
JNIAccessibleClass clazz = classesByClassObject.get(classObject);
if (clazz != null) {
JNIAccessibleMethod method = clazz.getMethod(descriptor);
if (method != null && method.isStatic() == isStatic) {
// safe because JNIAccessibleMethod is immutable (non-movable)
methodID = (JNIMethodId) Word.objectToUntrackedPointer(method);
}
}
return methodID;
}
use of com.oracle.svm.jni.nativeapi.JNIMethodId 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;
}
use of com.oracle.svm.jni.nativeapi.JNIMethodId 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