use of org.graalvm.jniutils.JNI.JString in project graal by oracle.
the class TruffleToLibGraalEntryPoints method getGraphDumpDirectory.
@TruffleToLibGraal(GetGraphDumpDirectory)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getGraphDumpDirectory")
public static JString getGraphDumpDirectory(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetGraphDumpDirectory, env);
try (JNIMethodScope s = scope) {
String path = DebugOptions.getDumpDirectory(HotSpotGraalOptionValues.defaultOptions());
scope.setObjectResult(createHSString(env, path));
} catch (IOException ioe) {
scope.setObjectResult(WordFactory.nullPointer());
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
scope.setObjectResult(WordFactory.nullPointer());
}
return scope.getObjectResult();
}
use of org.graalvm.jniutils.JNI.JString in project graal by oracle.
the class JNIExceptionWrapper method getClassName.
private static String getClassName(JNIEnv env, JThrowable throwableHandle) {
JClass classHandle = GetObjectClass(env, throwableHandle);
JString className = callGetClassName(env, classHandle);
return createString(env, className);
}
use of org.graalvm.jniutils.JNI.JString in project graal by oracle.
the class TruffleToLibGraalEntryPoints method openDebugContextScope.
@TruffleToLibGraal(OpenDebugContextScope)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_openDebugContextScope")
@SuppressWarnings({ "unused", "try" })
public static long openDebugContextScope(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, JString hsName, long compilationHandle) {
try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, OpenDebugContextScope, env)) {
TruffleDebugContext debugContext = LibGraalObjectHandles.resolve(handle, TruffleDebugContext.class);
String name = createString(env, hsName);
AutoCloseable scope;
if (compilationHandle == 0) {
scope = debugContext.scope(name);
} else {
TruffleCompilationIdentifier compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilationIdentifier.class);
scope = debugContext.scope(name, new TruffleDebugJavaMethod(compilation.getCompilable()));
}
if (scope == null) {
return 0;
}
long scopeHandle = LibGraalObjectHandles.create(scope);
return scopeHandle;
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
return 0;
}
}
use of org.graalvm.jniutils.JNI.JString in project graal by oracle.
the class TruffleToLibGraalEntryPoints method getCompilerConfigurationName.
@TruffleToLibGraal(GetCompilerConfigurationName)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getCompilerConfigurationName")
public static JString getCompilerConfigurationName(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetCompilerConfigurationName, env);
try (JNIMethodScope s = scope) {
HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
String name = compiler.getCompilerConfigurationName();
scope.setObjectResult(createHSString(env, name));
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
scope.setObjectResult(WordFactory.nullPointer());
}
return scope.getObjectResult();
}
use of org.graalvm.jniutils.JNI.JString 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