mirror of
https://github.com/wassname/ray.git
synced 2026-08-12 12:20:11 +08:00
[Java] add exitActor API for java (#10496)
This commit is contained in:
@@ -145,6 +145,13 @@ JNIEXPORT void JNICALL Java_io_ray_runtime_RayNativeRuntime_nativeInitialize(
|
||||
jobject java_return_objects =
|
||||
env->CallObjectMethod(java_task_executor, java_task_executor_execute,
|
||||
ray_function_array_list, args_array_list);
|
||||
// Check whether the exception is `IntentionalSystemExit`.
|
||||
jthrowable throwable = env->ExceptionOccurred();
|
||||
if (throwable &&
|
||||
env->IsInstanceOf(throwable,
|
||||
java_ray_intentional_system_exit_exception_class)) {
|
||||
return ray::Status::IntentionalSystemExit();
|
||||
}
|
||||
RAY_CHECK_JAVA_EXCEPTION(env);
|
||||
|
||||
// Process return objects.
|
||||
|
||||
@@ -54,6 +54,7 @@ jclass java_system_class;
|
||||
jmethodID java_system_gc;
|
||||
|
||||
jclass java_ray_exception_class;
|
||||
jclass java_ray_intentional_system_exit_exception_class;
|
||||
|
||||
jclass java_jni_exception_util_class;
|
||||
jmethodID java_jni_exception_util_get_stack_trace;
|
||||
@@ -171,6 +172,8 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
java_system_gc = env->GetStaticMethodID(java_system_class, "gc", "()V");
|
||||
|
||||
java_ray_exception_class = LoadClass(env, "io/ray/runtime/exception/RayException");
|
||||
java_ray_intentional_system_exit_exception_class =
|
||||
LoadClass(env, "io/ray/runtime/exception/RayIntentionalSystemExitException");
|
||||
|
||||
java_jni_exception_util_class = LoadClass(env, "io/ray/runtime/util/JniExceptionUtil");
|
||||
java_jni_exception_util_get_stack_trace = env->GetStaticMethodID(
|
||||
@@ -272,6 +275,7 @@ void JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
env->DeleteGlobalRef(java_map_entry_class);
|
||||
env->DeleteGlobalRef(java_system_class);
|
||||
env->DeleteGlobalRef(java_ray_exception_class);
|
||||
env->DeleteGlobalRef(java_ray_intentional_system_exit_exception_class);
|
||||
env->DeleteGlobalRef(java_jni_exception_util_class);
|
||||
env->DeleteGlobalRef(java_base_id_class);
|
||||
env->DeleteGlobalRef(java_function_descriptor_class);
|
||||
|
||||
@@ -94,6 +94,9 @@ extern jmethodID java_system_gc;
|
||||
/// RayException class
|
||||
extern jclass java_ray_exception_class;
|
||||
|
||||
/// RayIntentionalSystemExitException class
|
||||
extern jclass java_ray_intentional_system_exit_exception_class;
|
||||
|
||||
/// JniExceptionUtil class
|
||||
extern jclass java_jni_exception_util_class;
|
||||
/// getStackTrace method of JniExceptionUtil class
|
||||
|
||||
Reference in New Issue
Block a user