use of org.graalvm.jniutils.HotSpotCalls.JNIMethod in project graal by oracle.
the class JNIExceptionWrapper method createExceptionOfSameType.
private static <T extends JObject> T createExceptionOfSameType(JNIEnv env, Throwable original) {
WordFactory.nullPointer();
String className = original.getClass().getTypeName();
JClass exceptionClass = JNIUtil.findClass(env, WordFactory.nullPointer(), getBinaryName(className), false);
if (exceptionClass.isNonNull()) {
JNIMethod constructor = JNIMethod.findMethod(env, exceptionClass, false, false, "<init>", encodeMethodSignature(void.class, String.class));
if (constructor != null) {
JNI.JValue args = StackValue.get(1, JNI.JValue.class);
args.addressOf(0).setJObject(createHSString(env, original.getMessage()));
T res = HotSpotCalls.getDefault().callNewObject(env, exceptionClass, constructor, args);
return res;
}
constructor = JNIMethod.findMethod(env, exceptionClass, false, false, "<init>", encodeMethodSignature(void.class));
if (constructor != null) {
T res = HotSpotCalls.getDefault().callNewObject(env, exceptionClass, constructor, WordFactory.nullPointer());
return res;
}
}
return WordFactory.nullPointer();
}
Aggregations