lidavidm commented on code in PR #13465: URL: https://github.com/apache/arrow/pull/13465#discussion_r910224633
########## java/c/src/main/cpp/jni_wrapper.cc: ########## @@ -148,16 +176,99 @@ void release_exported(T* base) { // Mark released base->release = nullptr; } + +int ArrowArrayStreamGetSchema(ArrowArrayStream* stream, ArrowSchema* out) { + assert(stream->private_data != nullptr); + InnerPrivateData* private_data = + reinterpret_cast<InnerPrivateData*>(stream->private_data); + JNIEnvGuard guard(private_data->vm_); + JNIEnv* env = guard.env(); + + const long out_addr = static_cast<long>(reinterpret_cast<uintptr_t>(out)); + const int err_code = env->CallIntMethod(private_data->j_private_data_, + kPrivateDataGetSchemaMethod, out_addr); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); Review Comment: Normally the JNI side sets the last error, the check here is just a last-resort safeguard. I suppose this can be refactored though: copy the Java-side error to the C++ side after get_next/get_stream, and get_last_error only has to return the C++-side error; then get_next/get_stream can also update last_error_ if it ends up catching a stray error. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org