use of org.graalvm.jniutils.JNI.JClass in project graal by oracle.
the class JNIUtil method getSystemClassLoader.
/**
* Returns the {@link ClassLoader#getSystemClassLoader()}.
*/
public static JObject getSystemClassLoader(JNIEnv env) {
JClass clazz;
try (CCharPointerHolder className = CTypeConversion.toCString(JNIUtil.getBinaryName(ClassLoader.class.getName()))) {
clazz = JNIUtil.FindClass(env, className.get());
}
if (clazz.isNull()) {
throw new InternalError("No such class " + ClassLoader.class.getName());
}
JMethodID getClassLoaderId = findMethod(env, clazz, true, true, METHOD_GET_SYSTEM_CLASS_LOADER[0], METHOD_GET_SYSTEM_CLASS_LOADER[1]);
if (getClassLoaderId.isNull()) {
throw new InternalError(String.format("Cannot find method %s in class %s.", METHOD_GET_SYSTEM_CLASS_LOADER[0], ClassLoader.class.getName()));
}
return env.getFunctions().getCallStaticObjectMethodA().call(env, clazz, getClassLoaderId, nullPointer());
}
use of org.graalvm.jniutils.JNI.JClass in project graal by oracle.
the class TruffleToLibGraalEntryPoints method getInfopoints.
@TruffleToLibGraal(GetInfopoints)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getInfopoints")
@SuppressWarnings({ "unused", "try" })
public static JObjectArray getInfopoints(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetInfopoints, env);
try (JNIMethodScope s = scope) {
String[] infoPoints = LibGraalObjectHandles.resolve(handle, CompilationResultInfo.class).getInfopoints();
JClass componentType = FromLibGraalCalls.getJNIClass(env, String.class);
JObjectArray res = NewObjectArray(env, infoPoints.length, componentType, WordFactory.nullPointer());
for (int i = 0; i < infoPoints.length; i++) {
SetObjectArrayElement(env, res, i, createHSString(env, infoPoints[i]));
}
scope.setObjectResult(res);
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
scope.setObjectResult(WordFactory.nullPointer());
}
return scope.getObjectResult();
}
Aggregations