[ 
https://issues.apache.org/jira/browse/ARROW-16992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17564065#comment-17564065
 ] 

Kouhei Sutou commented on ARROW-16992:
--------------------------------------

I consider this and here are my opinions:

* We should use CMake for building share libraries ({{.so}}, {{.dylib}} and 
{{.dll}}) for JNI
* We should remove all JNI related codes from {{cpp/}}
* We should add {{java/CMakeLists.txt}} to build all shared libraries for JNI

Here are reasons of my opinions.

* Maven's shared library building support is too poor (Note that I'm not 
familiar with Maven. So this may be wrong.)
** -> Maintaining Maven configurations will be higher cost than maintaining 
CMake configurations
** It seems that we need to use Native Maven Plugin: 
https://www.mojohaus.org/maven-native/native-maven-plugin/
** Native Maven Plugin doesn't have a feature to choose shared object type for 
the current environment (e.g. {{.so}} for Linux)
*** We need to prepare one {{pom.xml}} per one shared object type (We need to 
create {{java/c/c-jni-so}}, {{java/c/c-jni-dylib}} and {{java/c/c-jni-dll}})
** Native Maven Plugin doesn't have a feature to find a library in the current 
environment
**** We can't detect installed Apache Arrow C++
* We can't build {{.jar}} that works on all environments (Linux, macOS and 
Windows) on one machine
** We keep using CI to build JNI related artifacts by {{dev/tasks/java-jars/}}
** -> Normal Java developers don't need to think about JNI and CMake. Java 
developers who work on JNI too need to know CMake but it will not too hard 
because they know C++.
** We need to build {{.so}}, {{.dylib}} and {{.dll}} for {{.jar}} that works on 
all environments
** If we build all shared libraries for JNI on one machine, we need to do 
cross-compiling
** Cross-compiling is very complex. We should avoid it as much as possible.
* We can simplify {{ci/scripts/java_jni_*}} used by {{dev/tasks/java-jars/}} by 
introducing {{java/CMakeLists.txt}}
** -> We can use general {{cmake ... && cmake --build ... install}} steps to 
build and install shared libraries for JNI

I can provide a PoC implementation of this idea if you need.


> [Java][C++] Separate JNI compilation & linking from main arrow CMakeLists 
> --------------------------------------------------------------------------
>
>                 Key: ARROW-16992
>                 URL: https://issues.apache.org/jira/browse/ARROW-16992
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++, Java
>            Reporter: Larry White
>            Priority: Major
>
> We need to separate the JNI elements from CMakeLists, with related 
> modifications to the CI build scripts likely. Separating the JNI portion 
> serves two related purposes:
>  # Simplify building JNI code against precompiled lib arrow C++ code
>  # Enable control of JNI build through Maven, rather than requiring Java devs 
> to work with CMake directly
> [~dsusanibara]
> [~kou] 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to