aboutsummaryrefslogtreecommitdiffstats
path: root/community/java-lz4/0003-prefer-system-lib.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/java-lz4/0003-prefer-system-lib.patch')
-rw-r--r--community/java-lz4/0003-prefer-system-lib.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/community/java-lz4/0003-prefer-system-lib.patch b/community/java-lz4/0003-prefer-system-lib.patch
new file mode 100644
index 0000000000..fd3720c746
--- /dev/null
+++ b/community/java-lz4/0003-prefer-system-lib.patch
@@ -0,0 +1,35 @@
+From 4727fc60f17a67b40c2bdf200a518a5d5708804c Mon Sep 17 00:00:00 2001
+From: Jakub Jirutka <jakub@jirutka.cz>
+Date: Thu, 7 Apr 2016 19:06:53 +0200
+Subject: [PATCH] Try to load lz4-java from java.library.path, then fallback to bundled
+
+Use system-provided lz4-java, if it's available on the java.library.path
+(the default location where Java looks for native libraries), and fallback
+to bundled binary if it's not. This allows user to use lz4 java even
+on systems that are not directly supported, like Linux with musl libc,
+uClibc etc.
+---
+ src/java/net/jpountz/util/Native.java | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/java/net/jpountz/util/Native.java b/src/java/net/jpountz/util/Native.java
+index 1856841..e25708e 100644
+--- a/src/java/net/jpountz/util/Native.java
++++ b/src/java/net/jpountz/util/Native.java
+@@ -71,6 +71,16 @@ public static synchronized void load() {
+ if (loaded) {
+ return;
+ }
++
++ // Try to load lz4-java (liblz4-java.so on Linux) from the java.library.path.
++ try {
++ System.loadLibrary("lz4-java");
++ loaded = true;
++ return;
++ } catch (UnsatisfiedLinkError ex) {
++ // Doesn't exist, so proceed to loading bundled library.
++ }
++
+ String resourceName = resourceName();
+ InputStream is = Native.class.getResourceAsStream(resourceName);
+ if (is == null) {