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 6 commits intoHDFGroup:developfrom
Conversation
Add org.scijava:native-lib-loader 2.5.0 under java/lib for consistent classpath use (examples cache includes the JAR alongside SLF4J). Define HDF5_JAVA_NATIVE_LIB_LOADER_JAR for downstream CMake consumers.
Introduce HDF5JavaNativeBundles.cmake to stage shared libraries under natives/<platform>/ (SciJava native-lib-loader layout), emit manifests with Implementation-Version, and add pom-native / pom-jni-native templates. Wire FFM and JNI hdf.hdf5lib builds and install the native-lib-loader JAR with other Java dependencies. Register add_subdirectory(java) before printing Maven deploy status so Java targets and globals exist before the examples subdirectory pulls in HDF5ExampleCache.cmake. Hdf5NativeLoader.java and compile-time classpath for the loader are added in the next commit.
Add Hdf5NativeLoader (thin wrapper over NativeLoader) and call it from H5 for FFM and JNI before loading JNI. Declare org.scijava:native-lib-loader in generated POMs and put the vendored JAR on the Java compile classpath. Preserves skip/override properties documented in INSTALL (following commit).
Include HDF5_JAVA_NATIVE_LIB_LOADER_JAR alongside logging JARs so unit tests compile and run the same classpath layout as production JARs.
Extend artifact validation for native classifier JARs and adjust workflows (ctest, maven-staging, maven-deploy) for the new native bundle layout and dependencies.
Describe hdf5-native / classpath layout, SciJava loader usage, Hdf5NativeLoader, and release notes touch-up for published artifacts.
|
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.
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.