Skip to content

Issue with arrow-c JNI and GraalVM 25 #866

@milenkovicm

Description

@milenkovicm

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

jclass local_class = env->FindClass(class_name);

The issues are at:

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,

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

if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK) {
return JNI_ERR;

return error returned by vm->GetEnv rather than JNI_ERR

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions