Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(java/driver/jni): add JNI bindings to native driver manager #2401

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lidavidm
Copy link
Member

Fixes #2027.

@lidavidm lidavidm force-pushed the gh-2027 branch 4 times, most recently from 1abdf50 to 7df6826 Compare January 3, 2025 04:19
@lidavidm lidavidm marked this pull request as ready for review January 3, 2025 04:38
@github-actions github-actions bot added this to the ADBC Libraries 16 milestone Jan 3, 2025
@lidavidm lidavidm removed this from the ADBC Libraries 16 milestone Jan 6, 2025
@lidavidm lidavidm requested a review from kou as a code owner March 7, 2025 06:21
@lidavidm
Copy link
Member Author

lidavidm commented Mar 7, 2025

Alright, this is now minimally functional and building, I'm going to add CI support, more tests/features, etc. in follow up PRs. It won't be part of releases for now (it has to be manually enabled).

Comment on lines +20 to +33
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h
COMMENT "Generate JNI headers"
# Force Maven to actually re-run the command
COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/target/headers
${CMAKE_CURRENT_SOURCE_DIR}/target/maven-status
COMMAND mvn --file ${CMAKE_CURRENT_SOURCE_DIR}/../.. -Pjni,javah
compile --also-make --projects :adbc-driver-jni
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeAdbc.java
)

add_library(adbc_driver_jni SHARED
src/main/cpp/jni_wrapper.cc
${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I originally did! 😂

But it has some problems. CMake can't resolve the Maven dependency tree. So the files we pass to add_jar have to be able to compile without any dependencies, including any dependencies on other ADBC classes. That meant duplicating code or writing slightly unnatural code in Java. So @laurentgo here suggested using CMake to invoke Maven to generate the headers instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java: Add JNI bindings to adbc.h
4 participants