use of org.graalvm.jniutils.JNIUtil.createHSString in project graal by oracle.
the class TruffleToLibGraalEntryPoints method getNodeTypes.
@TruffleToLibGraal(GetNodeTypes)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getNodeTypes")
@SuppressWarnings({ "unused", "try" })
public static JObjectArray getNodeTypes(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, boolean simpleNames) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetNodeTypes, env);
try (JNIMethodScope s = scope) {
GraphInfo orig = LibGraalObjectHandles.resolve(handle, GraphInfo.class);
String[] nodeTypes = orig.getNodeTypes(simpleNames);
JClass componentType = FromLibGraalCalls.getJNIClass(env, String.class);
JObjectArray res = NewObjectArray(env, nodeTypes.length, componentType, WordFactory.nullPointer());
for (int i = 0; i < nodeTypes.length; i++) {
SetObjectArrayElement(env, res, i, JNIUtil.createHSString(env, nodeTypes[i]));
}
scope.setObjectResult(res);
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
scope.setObjectResult(WordFactory.nullPointer());
}
return scope.getObjectResult();
}
use of org.graalvm.jniutils.JNIUtil.createHSString in project graal by oracle.
the class TruffleToLibGraalEntryPoints method getString.
@TruffleToLibGraal(GetSuppliedString)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getSuppliedString")
@SuppressWarnings({ "unused", "unchecked", "try" })
public static JString getString(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetSuppliedString, env);
try (JNIMethodScope s = scope) {
Supplier<String> orig = LibGraalObjectHandles.resolve(handle, Supplier.class);
if (orig != null) {
String stackTrace = orig.get();
scope.setObjectResult(JNIUtil.createHSString(env, stackTrace));
} else {
scope.setObjectResult(WordFactory.nullPointer());
}
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
scope.setObjectResult(WordFactory.nullPointer());
}
return scope.getObjectResult();
}
Aggregations