-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Describe the enhancement requested
I'm aware that graalvm is probably not supported, but I'm raising this as it might be simple fix.
There is a issue with env->FindClass in arrow-c when used with graalvm 25 (native image creates a shared library) Even all required classes are exposed for JNI in graalvm configuration env->FindClass wont be able to find a classes at
arrow-java/c/src/main/cpp/jni_wrapper.cc
Line 60 in 34060eb
| jclass local_class = env->FindClass(class_name); |
The issues are at:
arrow-java/c/src/main/cpp/jni_wrapper.cc
Lines 334 to 342 in 34060eb
| kObjectClass = CreateGlobalClassReference(env, "Ljava/lang/Object;"); | |
| kRuntimeExceptionClass = | |
| CreateGlobalClassReference(env, "Ljava/lang/RuntimeException;"); | |
| kPrivateDataClass = | |
| CreateGlobalClassReference(env, "Lorg/apache/arrow/c/jni/PrivateData;"); | |
| kCDataExceptionClass = | |
| CreateGlobalClassReference(env, "Lorg/apache/arrow/c/jni/CDataJniException;"); | |
| kStreamPrivateDataClass = CreateGlobalClassReference( | |
| env, "Lorg/apache/arrow/c/ArrayStreamExporter$ExportedArrayStreamPrivateData;"); |
where class names have L and ; at the start and end of the class name, so changing class names from Ljava/lang/Object; to java/lang/Object (and all other classes) will make problem go away.
kObjectClass = CreateGlobalClassReference(env, "java/lang/Object");
kRuntimeExceptionClass =
CreateGlobalClassReference(env, "java/lang/RuntimeException");
kPrivateDataClass =
CreateGlobalClassReference(env, "org/apache/arrow/c/jni/PrivateData");
kCDataExceptionClass =
CreateGlobalClassReference(env, "org/apache/arrow/c/jni/CDataJniException");
kStreamPrivateDataClass = CreateGlobalClassReference(
env, "org/apache/arrow/c/ArrayStreamExporter$ExportedArrayStreamPrivateData");looking at the spec,
- https://docs.oracle.com/en/java/javase/11/docs/specs/jni/functions.html#findclass
- https://docs.oracle.com/en/java/javase/21/docs/specs/jni/functions.html#findclass
it says correct format is without L and ';' for non array classes.
I did manage to fix this in 18.1 which could be built locally, unfortunately I can't make 18.3 run locally as instructions at https://arrow.apache.org/docs/developers/java/building.html are outdated with change to new repo
also, one small request, can
arrow-java/c/src/main/cpp/jni_wrapper.cc
Lines 330 to 331 in 34060eb
| if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK) { | |
| return JNI_ERR; |
return error returned by vm->GetEnv rather than JNI_ERR