Search in sources :

Example 1 with GetSuppliedString

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString 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();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Aggregations

TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)1 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)1 JString (org.graalvm.jniutils.JNI.JString)1 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)1 JNIUtil.createHSString (org.graalvm.jniutils.JNIUtil.createHSString)1 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1