[Java] add exitActor API for java (#10496)

This commit is contained in:
chaokunyang
2020-09-04 10:11:42 +08:00
committed by GitHub
parent 5e4db6ad24
commit cf3875bd8c
11 changed files with 195 additions and 0 deletions
@@ -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.
+4
View File
@@ -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);
+3
View File
@@ -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