Add hdf5-native Maven JARs and SciJava native-lib-loader integration#6356
Add hdf5-native Maven JARs and SciJava native-lib-loader integration#6356matteodg wants to merge 16 commits into
Conversation
|
Must Fix: The FFM [H5.java:314] calls Hdf5NativeLoader.loadBundledNativesIfPresent(false) with no try-catch in the static block. If native-lib-loader-2.5.0.jar is missing from the classpath, loading Hdf5NativeLoader will throw NoClassDefFoundError (because it imports org.scijava.nativelib.NativeLoader), which will cause an ExceptionInInitializerError that permanently prevents H5 from being used in that JVM. The JNI [H5.java:366-374] correctly wraps the call in catch (Throwable err), which handles this. The FFM version does not. The FFM path should have the same protection. Nice to have:
Moderate:
Low Severity
Consider using a simpler pattern like hdf5-(java|native|jni-native) or an array-based check.
Verify:
|
brtnfld
left a comment
There was a problem hiding this comment.
"Must Fix" needs to be addressed.
4779e1e to
f7e31e1
Compare
2a04368 to
cbf65fa
Compare
In both java/hdf/hdf5lib/H5.java (FFM) and java/src-jni/hdf/hdf5lib/H5.java (JNI), replace: with:
In java/cmake/HDF5JavaNativeBundles.cmake: Nice to have:
java/cmake/pom-native.xml.in and java/cmake/pom-jni-native.xml.in both end without a newline (\ No newline at end of file). Add a newline at the end of each.
The problem: isHdf5LibraryLoaded is set in two unrelated places with different meanings: In the bundled loader block — means "bundled hdf5 loaded" — split the flag's responsibilities): Replace the two flags with three, each with a single clear meaning: Change the early-exit guard from: to: Change the H5.H5dont_atexit() block from: to: This way isHdf5LibraryLoaded tracks only the bundled load result, isHdf5JavaLibraryLoaded tracks only the JNI bridge load result, and isInitialized guards against redundant re-entry. |
|
I'm trying to fix the failing builds due to this branch. |
39b6411 to
7815c86
Compare
fc18d24 to
e54f538
Compare
Download only the jextract 25 Unix binaries with correct platform detection and verify the installed version for consistent FFM CI output. Co-authored-by: Cursor <cursoragent@cursor.com>
Download only the jextract 25 Windows binary, verify the installed version, and use a forward-slash PATH entry on GitHub Windows runners. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Extract shared helpers for SciJava native JAR staging, manifest generation, and OS-activated Maven profile snippets. Wire HDF5JavaNativeBundles.cmake from FFM and JNI Java binding CMakeLists and move add_subdirectory(java) before the Maven deploy status message. Co-authored-by: Cursor <cursoragent@cursor.com>
Bundle libhdf5 under natives/<platform>/ with SciJava-mapped aliases and
install hdf5-native-*-{classifier}.jar plus pom-hdf5-native.xml.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add optional Maven bundles for shared zlib and libaec/szip with platform aliases and optional OS-activated binding-POM profile snippets. Co-authored-by: Cursor <cursoragent@cursor.com>
Add JNI bridge native bundle when HDF5JAVA_MAVEN_NATIVE_JNI is enabled. The standalone pom-jni-native template carries no Maven deps on libhdf5. Co-authored-by: Cursor <cursoragent@cursor.com>
Consolidate bundled zlib/szip/libhdf5 loading in loadBundledDependenciesBeforeHdf5(), use it from FFM/JNI H5.loadH5Lib and the slimmed hdf5_h_2 jextract patch, and layer binding POM dependencies (required hdf5-jni-native on java-jni; optional libhdf5 stack). Co-authored-by: Cursor <cursoragent@cursor.com>
Add artifact validation, Maven consumer smoke test with explicit native deps, FFM deflate smoke test, and CI workflow updates for native bundle artifacts. Co-authored-by: Cursor <cursoragent@cursor.com>
Describe optional libhdf5-stack artifacts, required hdf5-jni-native on java-jni, classpath-only vs system-native consumer paths, and runtime init contract. Co-authored-by: Cursor <cursoragent@cursor.com>
Centralize SciJava -link URL, native-lib-loader classpath handling, and hdf5_java_doc target creation for FFM and JNI binding trees. Co-authored-by: Cursor <cursoragent@cursor.com>
Wire HDF5JavaJavadoc.cmake with the FFM compile classpath so javadoc can
resolve SciJava {@link} references in Hdf5NativeLoader.
Co-authored-by: Cursor <cursoragent@cursor.com>
Wire HDF5JavaJavadoc.cmake with the JNI classpath so javadoc resolves SciJava cross-references when building the JNI binding tree. Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure doc builds with HDF5_BUILD_JAVA and HDF5_BUILD_DOC also generate hdf5_java_doc before the Doxygen hdf5lib_doc stamp target. Co-authored-by: Cursor <cursoragent@cursor.com>
c7077ef to
dd52995
Compare
|
This is now ready and it should be merged to develop after PR #6504 as that fixes some javadoc errors that prevent the builds to succeed. Thanks in advance for any review and suggestion. |
Fixes #6355
I created this with Cursor, as my knowledge of CMake is basically zero: I tried to do it myself, but I was not able. I tested this in Linux x86_64 and Windows x86_64 and it is creating the proper jar and pom.xml file, that I can install in my local Maven repository and depend on them from an example application. This was there is not need of installing HDF5 library or setting up
LD_LIBRARY_PATHanymore.This will be useful for the future of HDFView as well.