Please re-enable building the package in Java:packages repository. All the issues are fixed. - Update to v1.5.4.2 - Update patch: * 00-load-system-library.patch OBS-URL: https://build.opensuse.org/request/show/1072942 OBS-URL: https://build.opensuse.org/package/show/Java:packages/zstd-jni?expand=0&rev=4
105 lines
4.2 KiB
Diff
105 lines
4.2 KiB
Diff
diff -up zstd-jni-1.5.4-2/src/main/java/com/github/luben/zstd/util/Native.java.p00 zstd-jni-1.5.4-2/src/main/java/com/github/luben/zstd/util/Native.java
|
|
--- zstd-jni-1.5.4-2/src/main/java/com/github/luben/zstd/util/Native.java.p00 2023-03-06 16:19:40.169173840 +0300
|
|
+++ zstd-jni-1.5.4-2/src/main/java/com/github/luben/zstd/util/Native.java 2023-03-06 16:46:47.400276199 +0300
|
|
@@ -92,96 +92,11 @@ public enum Native {
|
|
String resourceName = resourceName();
|
|
|
|
String overridePath = System.getProperty(nativePathOverride);
|
|
- if (overridePath != null) {
|
|
+ if (overridePath != null)
|
|
// Do not fall back to auto-discovery - consumers know better
|
|
loadLibraryFile(overridePath);
|
|
- loaded = true;
|
|
- return;
|
|
- }
|
|
-
|
|
- // try to load the shared library directly from the JAR
|
|
- try {
|
|
- Class.forName("org.osgi.framework.BundleEvent"); // Simple OSGI env. check
|
|
- loadLibrary(libname);
|
|
- loaded = true;
|
|
- return;
|
|
- } catch (Throwable e) {
|
|
- // ignore both ClassNotFound and UnsatisfiedLinkError, and try other methods
|
|
- }
|
|
-
|
|
- InputStream is = Native.class.getResourceAsStream(resourceName);
|
|
- if (is == null) {
|
|
- // fallback to loading the zstd-jni from the system library path.
|
|
- // It also covers loading on Android.
|
|
- try {
|
|
- loadLibrary(libnameShort);
|
|
- loaded = true;
|
|
- return;
|
|
- } catch (UnsatisfiedLinkError e) {
|
|
- UnsatisfiedLinkError err = new UnsatisfiedLinkError(e.getMessage() + "\n" + errorMsg);
|
|
- err.setStackTrace(e.getStackTrace());
|
|
- throw err;
|
|
- }
|
|
- }
|
|
- File tempLib = null;
|
|
- FileOutputStream out = null;
|
|
- try {
|
|
- tempLib = File.createTempFile(libname, "." + libExtension(), tempFolder);
|
|
- // try to delete on exit, does not work on Windows
|
|
- tempLib.deleteOnExit();
|
|
- // copy to tempLib
|
|
- out = new FileOutputStream(tempLib);
|
|
- byte[] buf = new byte[4096];
|
|
- while (true) {
|
|
- int read = is.read(buf);
|
|
- if (read == -1) {
|
|
- break;
|
|
- }
|
|
- out.write(buf, 0, read);
|
|
- }
|
|
- try {
|
|
- out.flush();
|
|
- out.close();
|
|
- out = null;
|
|
- } catch (IOException e) {
|
|
- // ignore
|
|
- }
|
|
- try {
|
|
- loadLibraryFile(tempLib.getAbsolutePath());
|
|
- } catch (UnsatisfiedLinkError e) {
|
|
- // fall-back to loading the zstd-jni from the system library path
|
|
- try {
|
|
- loadLibrary(libnameShort);
|
|
- } catch (UnsatisfiedLinkError e1) {
|
|
- // display error in case problem with loading from temp folder
|
|
- // and from system library path - concatenate both messages
|
|
- UnsatisfiedLinkError err = new UnsatisfiedLinkError(
|
|
- e.getMessage() + "\n" +
|
|
- e1.getMessage() + "\n"+
|
|
- errorMsg);
|
|
- err.setStackTrace(e1.getStackTrace());
|
|
- throw err;
|
|
- }
|
|
- }
|
|
- loaded = true;
|
|
- } catch (IOException e) {
|
|
- // IO errors in extracting and writing the shared object in the temp dir
|
|
- ExceptionInInitializerError err = new ExceptionInInitializerError(
|
|
- "Cannot unpack " + libname + ": " + e.getMessage());
|
|
- err.setStackTrace(e.getStackTrace());
|
|
- throw err;
|
|
- } finally {
|
|
- try {
|
|
- is.close();
|
|
- if (out != null) {
|
|
- out.close();
|
|
- }
|
|
- if (tempLib != null && tempLib.exists()) {
|
|
- tempLib.delete();
|
|
- }
|
|
- } catch (IOException e) {
|
|
- // ignore
|
|
- }
|
|
- }
|
|
+ else
|
|
+ loadLibraryFile("@SYS_LIBRARY_PREFIX@/"+libname+".so");
|
|
+ loaded = true;
|
|
}
|
|
}
|