The package rpms/lz4-java.git has added or updated architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/lz4-java.git/commit/?id=0e7a00965....
Change:
-%ifnarch %{arm} aarch64 ppc64
Thanks.
Full change:
============
commit 451fa6b8537e48f9af40f07cc7c0882c25686ade
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Wed Jan 13 13:40:37 2021 -0500
remove hardcoded lib path in the Makefile
diff --git a/2-remove-cpptasks.patch b/2-remove-cpptasks.patch
index 42cd5dd..f896d55 100644
--- a/2-remove-cpptasks.patch
+++ b/2-remove-cpptasks.patch
@@ -34,8 +34,8 @@ index 0000000..01934f1
+generate_so:
+ gcc -fPIC -shared \
+ $(OBJECTS_DIR)/*.o \
-+ /usr/lib64/liblz4.so \
-+ /usr/lib64/libxxhash.so \
++ $(LIB_DIR)/liblz4.so \
++ $(LIB_DIR)/libxxhash.so \
+ -o $(BUILD_DIR)/jni/net/jpountz/util/$(PLATFORM)/$(ARCH)/liblz4-java.so
diff --git a/build.xml b/build.xml
index 1d4cff5..13d8ce3 100644
diff --git a/lz4-java.spec b/lz4-java.spec
index e7c4f9f..3e6f714 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -3,7 +3,7 @@
Name: lz4-java
Version: 1.7.1
-Release: 11%{?dist}
+Release: 12%{?dist}
Summary: LZ4 compression for Java
License: ASL 2.0
# GPLv2+ and BSD for lz4 and xxhash libs that are shared in liblz4-java.so
@@ -84,6 +84,7 @@ find -name '*.dylib' -print -delete
find -name '*.so' -print -delete
%build
+export LIB_DIR=%{_libdir}
%if 0%{?fedora} >= 33
export JAVA_HOME=/usr/lib/jvm/java-11/
%else
@@ -104,6 +105,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Wed Jan 13 2021 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-12
+- remove hardcoded lib directory in the Makefile
+
* Fri Jan 08 2021 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-11
- remove hardcoded "amd64" directory path in the Makefile
commit e52efa26f4d47a6c369e76566301b6a14040f304
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Fri Jan 8 16:40:03 2021 -0500
remove hardcoded amd64 path in the Makefile patch
diff --git a/2-remove-cpptasks.patch b/2-remove-cpptasks.patch
index 321bb7f..42cd5dd 100644
--- a/2-remove-cpptasks.patch
+++ b/2-remove-cpptasks.patch
@@ -1,6 +1,6 @@
diff --git a/Makefile b/Makefile
new file mode 100644
-index 0000000..bcd18ae
+index 0000000..01934f1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,33 @@
@@ -36,9 +36,9 @@ index 0000000..bcd18ae
+ $(OBJECTS_DIR)/*.o \
+ /usr/lib64/liblz4.so \
+ /usr/lib64/libxxhash.so \
-+ -o $(BUILD_DIR)/jni/net/jpountz/util/linux/amd64/liblz4-java.so
++ -o $(BUILD_DIR)/jni/net/jpountz/util/$(PLATFORM)/$(ARCH)/liblz4-java.so
diff --git a/build.xml b/build.xml
-index 1d4cff5..1bdc702 100644
+index 1d4cff5..13d8ce3 100644
--- a/build.xml
+++ b/build.xml
@@ -13,7 +13,6 @@
@@ -63,7 +63,7 @@ index 1d4cff5..1bdc702 100644
<target name="install-maven-ant-tasks"
unless="maven-ant-tasks.available">
<ivy:cachepath organisation="org.apache.maven"
module="maven-ant-tasks" revision="2.1.3"
inline="true" conf="default" transitive="true"
pathid="maven-ant-tasks.classpath"/>
-@@ -184,27 +176,10 @@
+@@ -184,27 +176,13 @@
</javah>
</target>
@@ -89,7 +89,10 @@ index 1d4cff5..1bdc702 100644
- <linker />
- <compilerarg value="-mmacosx-version-min=10.9"
if="isMacOS"/>
- </cpptasks:cc>
-+ <exec executable="make" failonerror="true"/>
++ <exec executable="make" failonerror="true">
++ <env key="ARCH" value="${os.arch}"/>
++ <env key="PLATFORM" value="${platform}"/>
++ </exec>
</target>
<target name="compile" depends="compile-java, compile-jni"
/>
diff --git a/lz4-java.spec b/lz4-java.spec
index 9d74daf..e7c4f9f 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -3,7 +3,7 @@
Name: lz4-java
Version: 1.7.1
-Release: 10%{?dist}
+Release: 11%{?dist}
Summary: LZ4 compression for Java
License: ASL 2.0
# GPLv2+ and BSD for lz4 and xxhash libs that are shared in liblz4-java.so
@@ -104,6 +104,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Fri Jan 08 2021 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-11
+- remove hardcoded "amd64" directory path in the Makefile
+
* Wed Dec 09 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-10
- remove BuildArch: noarch
commit ee3851b43cf9bed1941d46bdd5856c7fe48abe1a
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Wed Dec 9 10:19:26 2020 -0500
remove BuildArch: noarch
diff --git a/lz4-java.spec b/lz4-java.spec
index c7f85be..9d74daf 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -3,7 +3,7 @@
Name: lz4-java
Version: 1.7.1
-Release: 9%{?dist}
+Release: 10%{?dist}
Summary: LZ4 compression for Java
License: ASL 2.0
# GPLv2+ and BSD for lz4 and xxhash libs that are shared in liblz4-java.so
@@ -43,8 +43,6 @@ BuildRequires: objectweb-asm
BuildRequires: xerces-j2
BuildRequires: xxhash-devel
-BuildArch: noarch
-
%description
LZ4 compression for Java, based on Yann Collet's work.
This library provides access to two compression methods
@@ -106,6 +104,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Wed Dec 09 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-10
+- remove BuildArch: noarch
+
* Tue Dec 01 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-9
- run unit tests on classes that do not require randomizedtesting
- add liblz4-java.so generation step to Makefile
commit a60ea87713f7ea7ed7fa0f37addaca5b8a3f9580
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Tue Dec 1 14:02:53 2020 -0500
run unit tests that do not require randomizedtesting
diff --git a/0-remove-tests.patch b/0-remove-tests.patch
deleted file mode 100644
index a12b749..0000000
--- a/0-remove-tests.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/ivy-pure-java.xml b/ivy-pure-java.xml
-index 6e99e19..58f4c53 100644
---- a/ivy-pure-java.xml
-+++ b/ivy-pure-java.xml
-@@ -19,8 +19,4 @@
- <conf name="default" />
- <conf name="test" extends="default" />
- </configurations>
--
-- <dependencies>
-- <dependency org="com.carrotsearch.randomizedtesting"
name="junit4-ant" rev="2.7.3" transitive="true"
conf="test->*,!sources,!javadoc" />
-- </dependencies>
- </ivy-module>
-diff --git a/ivy.xml b/ivy.xml
-index 6643da7..4e3798c 100644
---- a/ivy.xml
-+++ b/ivy.xml
-@@ -19,8 +19,4 @@
- <conf name="default" />
- <conf name="test" extends="default" />
- </configurations>
--
-- <dependencies>
-- <dependency org="com.carrotsearch.randomizedtesting"
name="junit4-ant" rev="2.7.3" transitive="true"
conf="test->*,!sources,!javadoc" />
-- </dependencies>
- </ivy-module>
diff --git a/1-remove-unsafe.patch b/0-remove-unsafe.patch
similarity index 87%
rename from 1-remove-unsafe.patch
rename to 0-remove-unsafe.patch
index 90adaf3..416658f 100644
--- a/1-remove-unsafe.patch
+++ b/0-remove-unsafe.patch
@@ -776,96 +776,6 @@ index c4ef05e..b8b33d7 100644
assertEquals(LZ4JavaSafeSafeDecompressor.INSTANCE,
LZ4Factory.safeInstance().safeDecompressor());
}
-diff --git a/src/test/net/jpountz/lz4/LZ4Test.java
b/src/test/net/jpountz/lz4/LZ4Test.java
-index 161899c..6a3a597 100644
---- a/src/test/net/jpountz/lz4/LZ4Test.java
-+++ b/src/test/net/jpountz/lz4/LZ4Test.java
-@@ -247,11 +247,9 @@ public class LZ4Test extends AbstractLZ4Test {
- public void testRoundTrip(byte[] data, int off, int len) {
- for (LZ4Factory compressorFactory : Arrays.asList(
- LZ4Factory.nativeInstance(),
-- LZ4Factory.unsafeInstance(),
- LZ4Factory.safeInstance())) {
- for (LZ4Factory decompressorFactory : Arrays.asList(
- LZ4Factory.nativeInstance(),
-- LZ4Factory.unsafeInstance(),
- LZ4Factory.safeInstance())) {
- testRoundTrip(data, off, len, compressorFactory, decompressorFactory);
- }
-diff --git a/src/test/net/jpountz/xxhash/XXHash32Test.java
b/src/test/net/jpountz/xxhash/XXHash32Test.java
-index 98c9436..30f985d 100644
---- a/src/test/net/jpountz/xxhash/XXHash32Test.java
-+++ b/src/test/net/jpountz/xxhash/XXHash32Test.java
-@@ -74,18 +74,12 @@ public class XXHash32Test extends AbstractLZ4Test {
-
- private static XXHash32[] INSTANCES = new XXHash32[] {
- XXHashFactory.nativeInstance().hash32(),
-- XXHashFactory.unsafeInstance().hash32(),
- XXHashFactory.safeInstance().hash32(),
- new StreamingXXHash32Adapter() {
- protected StreamingXXHash32 streamingHash(int seed) {
- return XXHashFactory.nativeInstance().newStreamingHash32(seed);
- }
- },
-- new StreamingXXHash32Adapter() {
-- protected StreamingXXHash32 streamingHash(int seed) {
-- return XXHashFactory.unsafeInstance().newStreamingHash32(seed);
-- }
-- },
- new StreamingXXHash32Adapter() {
- protected StreamingXXHash32 streamingHash(int seed) {
- return XXHashFactory.safeInstance().newStreamingHash32(seed);
-@@ -150,13 +144,10 @@ public class XXHash32Test extends AbstractLZ4Test {
- long totalLen = 0;
- final int seed = randomInt();
- StreamingXXHash32 hash1 = XXHashFactory.nativeInstance().newStreamingHash32(seed);
-- StreamingXXHash32 hash2 = XXHashFactory.unsafeInstance().newStreamingHash32(seed);
- StreamingXXHash32 hash3 = XXHashFactory.safeInstance().newStreamingHash32(seed);
- while (totalLen < (1L << 33)) {
- hash1.update(bytes, off, len);
-- hash2.update(bytes, off, len);
- hash3.update(bytes, off, len);
-- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
- totalLen += len;
- }
-diff --git a/src/test/net/jpountz/xxhash/XXHash64Test.java
b/src/test/net/jpountz/xxhash/XXHash64Test.java
-index dadbeda..b767c99 100644
---- a/src/test/net/jpountz/xxhash/XXHash64Test.java
-+++ b/src/test/net/jpountz/xxhash/XXHash64Test.java
-@@ -74,18 +74,12 @@ public class XXHash64Test extends AbstractLZ4Test {
-
- private static XXHash64[] INSTANCES = new XXHash64[] {
- XXHashFactory.nativeInstance().hash64(),
-- XXHashFactory.unsafeInstance().hash64(),
- XXHashFactory.safeInstance().hash64(),
- new StreamingXXHash64Adapter() {
- protected StreamingXXHash64 streamingHash(long seed) {
- return XXHashFactory.nativeInstance().newStreamingHash64(seed);
- }
- },
-- new StreamingXXHash64Adapter() {
-- protected StreamingXXHash64 streamingHash(long seed) {
-- return XXHashFactory.unsafeInstance().newStreamingHash64(seed);
-- }
-- },
- new StreamingXXHash64Adapter() {
- protected StreamingXXHash64 streamingHash(long seed) {
- return XXHashFactory.safeInstance().newStreamingHash64(seed);
-@@ -155,13 +149,10 @@ public class XXHash64Test extends AbstractLZ4Test {
- long totalLen = 0;
- final long seed = randomLong();
- StreamingXXHash64 hash1 = XXHashFactory.nativeInstance().newStreamingHash64(seed);
-- StreamingXXHash64 hash2 = XXHashFactory.unsafeInstance().newStreamingHash64(seed);
- StreamingXXHash64 hash3 = XXHashFactory.safeInstance().newStreamingHash64(seed);
- while (totalLen < (1L << 33)) {
- hash1.update(bytes, off, len);
-- hash2.update(bytes, off, len);
- hash3.update(bytes, off, len);
-- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
- totalLen += len;
- }
diff --git a/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
b/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
index c410220..2aae562 100644
--- a/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
diff --git a/2-remove-comments-from-templates.patch
b/1-remove-comments-from-templates.patch
similarity index 100%
rename from 2-remove-comments-from-templates.patch
rename to 1-remove-comments-from-templates.patch
diff --git a/3-remove-cpptasks.patch b/2-remove-cpptasks.patch
similarity index 87%
rename from 3-remove-cpptasks.patch
rename to 2-remove-cpptasks.patch
index c03318b..321bb7f 100644
--- a/3-remove-cpptasks.patch
+++ b/2-remove-cpptasks.patch
@@ -1,9 +1,9 @@
diff --git a/Makefile b/Makefile
new file mode 100644
-index 0000000..d762404
+index 0000000..bcd18ae
--- /dev/null
+++ b/Makefile
-@@ -0,0 +1,26 @@
+@@ -0,0 +1,33 @@
+CC = gcc
+
+BUILD_DIR = build
@@ -15,27 +15,33 @@ index 0000000..d762404
+LIBS = -llz4 -lxxhash
+JNI_PREFIX = net_jpountz_
+
-+default: all move_objects
++default: all move_objects generate_so
+
+all:
-+ $(CC) -I $(JNI_HEADERS_DIR) \
++ $(CC) -fPIC -I $(JNI_HEADERS_DIR) \
+ $(INCLUDE) \
+ $(LIBS) \
+ -c $(JNI_SOURCES_DIR)/$(JNI_PREFIX)lz4_LZ4JNI.c
+
-+ $(CC) -I $(JNI_HEADERS_DIR) \
++ $(CC) -fPIC -I $(JNI_HEADERS_DIR) \
+ $(INCLUDE) \
+ $(LIBS) \
+ -c $(JNI_SOURCES_DIR)/$(JNI_PREFIX)xxhash_XXHashJNI.c
+
+move_objects:
+ mv *.o $(OBJECTS_DIR)
-\ No newline at end of file
++
++generate_so:
++ gcc -fPIC -shared \
++ $(OBJECTS_DIR)/*.o \
++ /usr/lib64/liblz4.so \
++ /usr/lib64/libxxhash.so \
++ -o $(BUILD_DIR)/jni/net/jpountz/util/linux/amd64/liblz4-java.so
diff --git a/build.xml b/build.xml
-index 7a63933..dc1a112 100644
+index 1d4cff5..1bdc702 100644
--- a/build.xml
+++ b/build.xml
-@@ -15,7 +15,6 @@
+@@ -13,7 +13,6 @@
-->
<project name="lz4" default="dist" basedir="."
@@ -43,7 +49,7 @@ index 7a63933..dc1a112 100644
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:junit4="antlib:com.carrotsearch.junit4"
xmlns:mvn="antlib:org.apache.maven.artifact.ant">
-@@ -80,13 +79,6 @@
+@@ -78,13 +77,6 @@
<get
src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.ver...
dest="${user.home}/.ant/lib/${ivy.jar.name}"/>
</target>
@@ -57,7 +63,7 @@ index 7a63933..dc1a112 100644
<target name="install-maven-ant-tasks"
unless="maven-ant-tasks.available">
<ivy:cachepath organisation="org.apache.maven"
module="maven-ant-tasks" revision="2.1.3"
inline="true" conf="default" transitive="true"
pathid="maven-ant-tasks.classpath"/>
-@@ -197,27 +189,10 @@
+@@ -184,27 +176,10 @@
</javah>
</target>
diff --git a/3-remove-randomizedtesting-tests.patch
b/3-remove-randomizedtesting-tests.patch
new file mode 100644
index 0000000..c7d2282
--- /dev/null
+++ b/3-remove-randomizedtesting-tests.patch
@@ -0,0 +1,1689 @@
+diff --git a/.classpath b/.classpath
+index 058b340..c48898b 100644
+--- a/.classpath
++++ b/.classpath
+@@ -7,7 +7,5 @@
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib"
path="lib/hamcrest-core-1.1.jar"/>
+- <classpathentry kind="lib" path="lib/junit-4.10.jar"/>
+- <classpathentry kind="lib"
path="lib/randomizedtesting-runner-2.0.9.jar"/>
+ <classpathentry kind="output" path="bin"/>
+ </classpath>
+
+diff --git a/build.xml b/build.xml
+index 1bdc702..919386f 100644
+--- a/build.xml
++++ b/build.xml
+@@ -14,7 +14,6 @@
+
+ <project name="lz4" default="dist" basedir="."
+ xmlns:ivy="antlib:org.apache.ivy.ant"
+- xmlns:junit4="antlib:com.carrotsearch.junit4"
+ xmlns:mvn="antlib:org.apache.maven.artifact.ant">
+
+ <property name="src" location="src"/>
+@@ -105,15 +104,6 @@
+ <ivy:retrieve />
+ </target>
+
+- <target name="install-junit4" depends="init"
unless="junit4.available">
+- <taskdef uri="antlib:com.carrotsearch.junit4">
+- <classpath>
+- <fileset dir="${lib}" includes="*.jar" />
+- </classpath>
+- </taskdef>
+- <property name="junit4.available" value="true" />
+- </target>
+-
+ <target name="generate-sources" depends="init">
+ <ivy:cachepath organisation="org.mvel" module="mvel2"
revision="2.3.2.Final"
+ inline="true" conf="default" transitive="true"
pathid="mvel.classpath"/>
+@@ -236,37 +226,14 @@
+ <antcall target="-test" />
+ </target>
+
+- <target name="-test" depends="compile-tests,
install-junit4">
+- <mkdir dir="${build}/tests" />
+- <junit4:junit4
+- dir="${java.io.tmpdir}"
+- maxmemory="300m"
+- parallelism="auto">
+- <assertions>
+- <enable package="net.jpountz.lz4"/>
+- </assertions>
++ <target name="-test" depends="compile-tests">
++ <junit printsummary="on" showoutput="true"
failureProperty="test.failure">
+ <classpath refid="${prop.test.classpath}" />
+- <fileset dir="${build}/test-classes/">
+- <include name="**/*Test.class" />
+- <exclude name="**/*$*" />
+- <exclude name="**/Abstract*" />
+- </fileset>
+- <listeners>
+- <junit4:report-text
+- showThrowable="true"
+- showStackTraces="true"
+- showOutput="never"
+-
+- showStatusOk="true"
+- showStatusError="true"
+- showStatusFailure="true"
+- showStatusIgnored="true"
+-
+- showSuiteSummary="false" />
+- <!-- For enkins -->
+- <junit4:report-ant-xml dir="${build}/tests" />
+- </listeners>
+- </junit4:junit4>
++ <test name="net.jpountz.lz4.LZ4FrameIOStreamTest" />
++ <test name="net.jpountz.lz4.LZ4FactoryTest" />
++ <test name="net.jpountz.xxhash.XXHashFactoryTest" />
++ </junit>
++ <fail message="tests failed" if="test.failure" />
+ </target>
+
+ <target name="test-skip-jni" description="run tests without building
JNI">
+diff --git a/ivy-pure-java.xml b/ivy-pure-java.xml
+index 6e99e19..9c1c99b 100644
+--- a/ivy-pure-java.xml
++++ b/ivy-pure-java.xml
+@@ -21,6 +21,6 @@
+ </configurations>
+
+ <dependencies>
+- <dependency org="com.carrotsearch.randomizedtesting"
name="junit4-ant" rev="2.7.3" transitive="true"
conf="test->*,!sources,!javadoc" />
++ <dependency org="junit" name="junit" rev="4.12"
conf="test->default" />
+ </dependencies>
+ </ivy-module>
+diff --git a/ivy.xml b/ivy.xml
+index 6643da7..e5a9620 100644
+--- a/ivy.xml
++++ b/ivy.xml
+@@ -21,6 +21,6 @@
+ </configurations>
+
+ <dependencies>
+- <dependency org="com.carrotsearch.randomizedtesting"
name="junit4-ant" rev="2.7.3" transitive="true"
conf="test->*,!sources,!javadoc" />
++ <dependency org="junit" name="junit" rev="4.12"
conf="test->default" />
+ </dependencies>
+ </ivy-module>
+diff --git a/src/test/net/jpountz/lz4/AbstractLZ4Test.java
b/src/test/net/jpountz/lz4/AbstractLZ4Test.java
+deleted file mode 100644
+index 8c5cd38..0000000
+--- a/src/test/net/jpountz/lz4/AbstractLZ4Test.java
++++ /dev/null
+@@ -1,257 +0,0 @@
+-package net.jpountz.lz4;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import java.io.ByteArrayOutputStream;
+-import java.io.IOException;
+-import java.io.InputStream;
+-import java.nio.ByteBuffer;
+-import java.nio.ByteOrder;
+-import java.util.Arrays;
+-
+-import com.carrotsearch.randomizedtesting.RandomizedTest;
+-
+-public abstract class AbstractLZ4Test extends RandomizedTest {
+-
+- public interface Tester<T> {
+-
+- T allocate(int length);
+- T copyOf(byte[] array);
+- byte[] copyOf(T data, int off, int len);
+- int maxCompressedLength(int len);
+- int compress(LZ4Compressor compressor, T src, int srcOff, int srcLen, T dest, int
destOff, int maxDestLen);
+- int decompress(LZ4FastDecompressor decompressor, T src, int srcOff, T dest, int
destOff, int destLen);
+- int decompress(LZ4SafeDecompressor decompressor, T src, int srcOff, int srcLen, T
dest, int destOff, int maxDestLen);
+- void fill(T instance, byte b);
+-
+- public static class ByteArrayTester implements Tester<byte[]> {
+-
+- @Override
+- public byte[] allocate(int length) {
+- return new byte[length];
+- }
+-
+- @Override
+- public byte[] copyOf(byte[] array) {
+- return Arrays.copyOf(array, array.length);
+- }
+-
+- @Override
+- public byte[] copyOf(byte[] data, int off, int len) {
+- return Arrays.copyOfRange(data, off, off + len);
+- }
+-
+- @Override
+- public int maxCompressedLength(int len) {
+- return LZ4Utils.maxCompressedLength(len);
+- }
+-
+- @Override
+- public int compress(LZ4Compressor compressor, byte[] src, int srcOff,
+- int srcLen, byte[] dest, int destOff, int maxDestLen) {
+- return compressor.compress(src, srcOff, srcLen, dest, destOff, maxDestLen);
+- }
+-
+- @Override
+- public int decompress(LZ4FastDecompressor decompressor,
+- byte[] src, int srcOff, byte[] dest, int destOff, int destLen) {
+- return decompressor.decompress(src, srcOff, dest, destOff, destLen);
+- }
+-
+- @Override
+- public int decompress(LZ4SafeDecompressor decompressor,
+- byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen)
{
+- return decompressor.decompress(src, srcOff, srcLen, dest, destOff, maxDestLen);
+- }
+-
+- @Override
+- public void fill(byte[] instance, byte b) {
+- Arrays.fill(instance, b);
+- }
+- }
+- public static final Tester<byte[]> BYTE_ARRAY = new ByteArrayTester();
+- public static final Tester<byte[]> BYTE_ARRAY_WITH_LENGTH = new
ByteArrayTester() {
+- @Override
+- public int compress(LZ4Compressor compressor, byte[] src, int srcOff,
+- int srcLen, byte[] dest, int destOff, int maxDestLen) {
+- return new LZ4CompressorWithLength(compressor).compress(src, srcOff, srcLen,
dest, destOff, maxDestLen);
+- }
+-
+- @Override
+- public int decompress(LZ4FastDecompressor decompressor,
+- byte[] src, int srcOff, byte[] dest, int destOff, int destLen) {
+- return new LZ4DecompressorWithLength(decompressor).decompress(src, srcOff, dest,
destOff);
+- }
+-
+- @Override
+- public int decompress(LZ4SafeDecompressor decompressor,
+- byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen)
{
+- return -1;
+- }
+- };
+-
+- public static class ByteBufferTester implements Tester<ByteBuffer> {
+-
+- @Override
+- public ByteBuffer allocate(int length) {
+- ByteBuffer bb;
+- int slice = randomInt(5);
+- if (randomBoolean()) {
+- bb = ByteBuffer.allocate(length + slice);
+- } else {
+- bb = ByteBuffer.allocateDirect(length + slice);
+- }
+- bb.position(slice);
+- bb = bb.slice();
+- if (randomBoolean()) {
+- bb.order(ByteOrder.LITTLE_ENDIAN);
+- } else {
+- bb.order(ByteOrder.BIG_ENDIAN);
+- }
+- return bb;
+- }
+-
+- @Override
+- public ByteBuffer copyOf(byte[] array) {
+- ByteBuffer bb = allocate(array.length).put(array);
+- if (randomBoolean()) {
+- bb = bb.asReadOnlyBuffer();
+- }
+- bb.position(0);
+- return bb;
+- }
+-
+- @Override
+- public byte[] copyOf(ByteBuffer data, int off, int len) {
+- byte[] copy = new byte[len];
+- data.position(off);
+- data.get(copy);
+- return copy;
+- }
+-
+- @Override
+- public int maxCompressedLength(int len) {
+- return LZ4Utils.maxCompressedLength(len);
+- }
+-
+- @Override
+- public int compress(LZ4Compressor compressor, ByteBuffer src, int srcOff,
+- int srcLen, ByteBuffer dest, int destOff, int maxDestLen) {
+- return compressor.compress(src, srcOff, srcLen, dest, destOff, maxDestLen);
+- }
+-
+- @Override
+- public int decompress(LZ4FastDecompressor decompressor, ByteBuffer src,
+- int srcOff, ByteBuffer dest, int destOff, int destLen) {
+- return decompressor.decompress(src, srcOff, dest, destOff, destLen);
+- }
+-
+- @Override
+- public int decompress(LZ4SafeDecompressor decompressor, ByteBuffer src,
+- int srcOff, int srcLen, ByteBuffer dest, int destOff, int maxDestLen) {
+- return decompressor.decompress(src, srcOff, srcLen, dest, destOff, maxDestLen);
+- }
+-
+- @Override
+- public void fill(ByteBuffer instance, byte b) {
+- for (int i = 0; i < instance.capacity(); ++i) {
+- instance.put(i, b);
+- }
+- }
+- }
+- public static final Tester<ByteBuffer> BYTE_BUFFER = new ByteBufferTester();
+- public static final Tester<ByteBuffer> BYTE_BUFFER_WITH_LENGTH = new
ByteBufferTester() {
+- @Override
+- public int compress(LZ4Compressor compressor, ByteBuffer src, int srcOff,
+- int srcLen, ByteBuffer dest, int destOff, int maxDestLen) {
+- return new LZ4CompressorWithLength(compressor).compress(src, srcOff, srcLen,
dest, destOff, maxDestLen);
+- }
+-
+- @Override
+- public int decompress(LZ4FastDecompressor decompressor, ByteBuffer src,
+- int srcOff, ByteBuffer dest, int destOff, int destLen) {
+- return new LZ4DecompressorWithLength(decompressor).decompress(src, srcOff, dest,
destOff);
+- }
+-
+- @Override
+- public int decompress(LZ4SafeDecompressor decompressor, ByteBuffer src,
+- int srcOff, int srcLen, ByteBuffer dest, int destOff, int maxDestLen) {
+- return -1;
+- }
+- };
+- }
+-
+- protected class RandomBytes {
+- private final byte[] bytes;
+- RandomBytes(int n) {
+- assert n > 0 && n <= 256;
+- bytes = new byte[n];
+- for (int i = 0; i < n; ++i) {
+- bytes[i] = (byte) randomInt(255);
+- }
+- }
+- byte next() {
+- final int i = randomInt(bytes.length - 1);
+- return bytes[i];
+- }
+- }
+-
+- protected static byte[] readResource(String resource) throws IOException {
+- InputStream is = LZ4Test.class.getResourceAsStream(resource);
+- if (is == null) {
+- throw new IllegalStateException("Cannot find " + resource);
+- }
+- byte[] buf = new byte[4096];
+- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+- try {
+- while (true) {
+- final int read = is.read(buf);
+- if (read == -1) {
+- break;
+- }
+- baos.write(buf, 0, read);
+- }
+- } finally {
+- is.close();
+- }
+- return baos.toByteArray();
+- }
+-
+- protected byte[] randomArray(int len, int n) {
+- byte[] result = new byte[len];
+- RandomBytes randomBytes = new RandomBytes(n);
+- for (int i = 0; i < result.length; ++i) {
+- result[i] = randomBytes.next();
+- }
+- return result;
+- }
+-
+- protected ByteBuffer copyOf(byte[] bytes, int offset, int len) {
+- ByteBuffer buffer;
+- if (randomBoolean()) {
+- buffer = ByteBuffer.allocate(bytes.length);
+- } else {
+- buffer = ByteBuffer.allocateDirect(bytes.length);
+- }
+- buffer.put(bytes);
+- buffer.position(offset);
+- buffer.limit(offset + len);
+- if (randomBoolean()) {
+- buffer = buffer.asReadOnlyBuffer();
+- }
+- return buffer;
+- }
+-
+-}
+diff --git a/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
b/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
+deleted file mode 100644
+index 9d6fc5b..0000000
+--- a/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
++++ /dev/null
+@@ -1,347 +0,0 @@
+-package net.jpountz.lz4;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import java.io.ByteArrayInputStream;
+-import java.io.ByteArrayOutputStream;
+-import java.io.FilterInputStream;
+-import java.io.FilterOutputStream;
+-import java.io.IOException;
+-import java.io.InputStream;
+-import java.io.OutputStream;
+-import java.nio.charset.Charset;
+-import java.util.Arrays;
+-import java.util.zip.Adler32;
+-import java.util.zip.CRC32;
+-import java.util.zip.Checksum;
+-
+-import net.jpountz.xxhash.XXHashFactory;
+-
+-import org.junit.Test;
+-import static org.junit.Assert.*;
+-
+-import com.carrotsearch.randomizedtesting.annotations.Repeat;
+-
+-public class LZ4BlockStreamingTest extends AbstractLZ4Test {
+-
+- // An input stream that might read less data than it is able to
+- class MockInputStream extends FilterInputStream {
+-
+- MockInputStream(InputStream in) {
+- super(in);
+- }
+-
+- @Override
+- public int read(byte[] b, int off, int len) throws IOException {
+- return super.read(b, off, randomIntBetween(0, len));
+- }
+-
+- @Override
+- public long skip(long n) throws IOException {
+- return super.skip(randomInt((int) Math.min(n, Integer.MAX_VALUE)));
+- }
+-
+- }
+-
+- // an output stream that delays the actual writes
+- class MockOutputStream extends FilterOutputStream {
+-
+- private final byte[] buffer;
+- private int delayedBytes;
+-
+- MockOutputStream(OutputStream out) {
+- super(out);
+- buffer = new byte[randomIntBetween(10, 1000)];
+- delayedBytes = 0;
+- }
+-
+- private void flushIfNecessary() throws IOException {
+- if (delayedBytes == buffer.length) {
+- flushPendingData();
+- }
+- }
+-
+- private void flushPendingData() throws IOException {
+- out.write(buffer, 0, delayedBytes);
+- delayedBytes = 0;
+- }
+-
+- @Override
+- public void write(int b) throws IOException {
+- if (rarely()) {
+- flushPendingData();
+- } else {
+- flushIfNecessary();
+- }
+- buffer[delayedBytes++] = (byte) b;
+- }
+-
+- @Override
+- public void write(byte[] b, int off, int len) throws IOException {
+- if (rarely()) {
+- flushPendingData();
+- }
+- if (len + delayedBytes > buffer.length) {
+- flushPendingData();
+- delayedBytes = randomInt(Math.min(len, buffer.length));
+- out.write(b, off, len - delayedBytes);
+- System.arraycopy(b, off + len - delayedBytes, buffer, 0, delayedBytes);
+- } else {
+- System.arraycopy(b, off, buffer, delayedBytes, len);
+- delayedBytes += len;
+- }
+- }
+-
+- @Override
+- public void write(byte[] b) throws IOException {
+- write(b, 0, b.length);
+- }
+-
+- @Override
+- public void flush() throws IOException {
+- // no-op
+- }
+-
+- @Override
+- public void close() throws IOException {
+- flushPendingData();
+- out.close();
+- }
+-
+- }
+-
+- private InputStream open(byte[] data) {
+- return new MockInputStream(new ByteArrayInputStream(data));
+- }
+-
+- private OutputStream wrap(OutputStream other) {
+- return new MockOutputStream(other);
+- }
+-
+- @Test
+- @Repeat(iterations=5)
+- public void testRoundtripGeo() throws IOException {
+- testRoundTrip("/calgary/geo");
+- }
+-
+- @Test
+- @Repeat(iterations=5)
+- public void testRoundtripBook1() throws IOException {
+- testRoundTrip("/calgary/book1");
+- }
+-
+- @Test
+- @Repeat(iterations=5)
+- public void testRoundtripPic() throws IOException {
+- testRoundTrip("/calgary/pic");
+- }
+-
+- public void testRoundTrip(String resource) throws IOException {
+- testRoundTrip(readResource(resource));
+- }
+-
+- public void testRoundTrip(byte[] data) throws IOException {
+- final ByteArrayOutputStream compressed = new ByteArrayOutputStream();
+- final int blockSize;
+- switch (randomInt(2)) {
+- case 0:
+- blockSize = LZ4BlockOutputStream.MIN_BLOCK_SIZE;
+- break;
+- case 1:
+- blockSize = LZ4BlockOutputStream.MAX_BLOCK_SIZE;
+- break;
+- default:
+- blockSize = randomIntBetween(LZ4BlockOutputStream.MIN_BLOCK_SIZE,
LZ4BlockOutputStream.MAX_BLOCK_SIZE);
+- break;
+- }
+- final LZ4Compressor compressor = randomBoolean()
+- ? LZ4Factory.fastestInstance().fastCompressor()
+- : LZ4Factory.fastestInstance().highCompressor();
+- final Checksum checksum;
+- switch (randomInt(2)) {
+- case 0:
+- checksum = new Adler32();
+- break;
+- case 1:
+- checksum = new CRC32();
+- break;
+- default:
+- checksum =
XXHashFactory.fastestInstance().newStreamingHash32(randomInt()).asChecksum();
+- break;
+- }
+- final boolean syncFlush = randomBoolean();
+- final LZ4BlockOutputStream os = new LZ4BlockOutputStream(wrap(compressed),
blockSize, compressor, checksum, syncFlush);
+- final int half = data.length / 2;
+- switch (randomInt(2)) {
+- case 0:
+- os.write(data, 0, half);
+- for (int i = half; i < data.length; ++i) {
+- os.write(data[i]);
+- }
+- break;
+- case 1:
+- for (int i = 0; i < half; ++i) {
+- os.write(data[i]);
+- }
+- os.write(data, half, data.length - half);
+- break;
+- case 2:
+- os.write(data, 0, data.length);
+- break;
+- }
+- os.close();
+-
+- final LZ4FastDecompressor decompressor =
LZ4Factory.fastestInstance().fastDecompressor();
+- InputStream is = new LZ4BlockInputStream(open(compressed.toByteArray()),
decompressor, checksum);
+- assertFalse(is.markSupported());
+- try {
+- is.mark(1);
+- is.reset();
+- assertFalse(true);
+- } catch (IOException e) {
+- // OK
+- }
+- byte[] restored = new byte[data.length + 1000];
+- int read = 0;
+- while (true) {
+- if (randomFloat() < 0.01f) {
+- final int r = is.read(restored, read, restored.length - read);
+- if (r == -1) {
+- break;
+- } else {
+- read += r;
+- }
+- } else {
+- final int b = is.read();
+- if (b == -1) {
+- break;
+- } else {
+- restored[read++] = (byte) b;
+- }
+- }
+- }
+- is.close();
+- assertEquals(data.length, read);
+- assertArrayEquals(data, Arrays.copyOf(restored, read));
+-
+- // test skip
+- final int offset = data.length <= 1 ? 0 : randomInt(data.length - 1);
+- final int length = randomInt(data.length - offset);
+- is = new LZ4BlockInputStream(open(compressed.toByteArray()), decompressor,
checksum);
+- restored = new byte[length + 1000];
+- read = 0;
+- while (read < offset) {
+- final long skipped = is.skip(offset - read);
+- assertTrue(skipped >= 0);
+- read += skipped;
+- }
+- read = 0;
+- while (read < length) {
+- final int r = is.read(restored, read, length - read);
+- assertTrue(r >= 0);
+- read += r;
+- }
+- is.close();
+- assertArrayEquals(Arrays.copyOfRange(data, offset, offset + length),
Arrays.copyOfRange(restored, 0, length));
+- }
+-
+- @Test
+- @Repeat(iterations=20)
+- public void testRoundtripRandom() throws IOException {
+- final int size = randomFloat() < 0.1f ? randomInt(5) : randomInt(1 << 20);
+- final byte[] data = randomArray(size, randomBoolean() ? randomIntBetween(1, 5) :
randomIntBetween(6, 100));
+- testRoundTrip(data);
+- }
+-
+- @Test
+- public void testRoundtripEmpty() throws IOException {
+- testRoundTrip(new byte[0]);
+- }
+-
+- @Test
+- public void testDoubleClose() throws IOException {
+- final byte[] testBytes =
"Testing!".getBytes(Charset.forName("UTF-8"));
+-
+- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+- LZ4BlockOutputStream out = new LZ4BlockOutputStream(bytes);
+-
+- out.write(testBytes);
+-
+- out.close();
+- out.close();
+-
+- LZ4BlockInputStream in = new LZ4BlockInputStream(new
ByteArrayInputStream(bytes.toByteArray()));
+- byte[] actual = new byte[testBytes.length];
+- in.read(actual);
+-
+- assertArrayEquals(testBytes, actual);
+-
+- in.close();
+- in.close();
+- }
+-
+- private static int readFully(InputStream in, byte[] b) throws IOException {
+- int total;
+- int result;
+- for (total = 0; total < b.length; total += result) {
+- result = in.read(b, total, b.length - total);
+- if(result == -1) {
+- break;
+- }
+- }
+- return total;
+- }
+-
+- @Test
+- public void testConcatenationOfSerializedStreams() throws IOException {
+- final byte[] testBytes1 = randomArray(64, 256);
+- final byte[] testBytes2 = randomArray(64, 256);
+- byte[] expected = new byte[128];
+- System.arraycopy(testBytes1, 0, expected, 0, 64);
+- System.arraycopy(testBytes2, 0, expected, 64, 64);
+-
+- ByteArrayOutputStream bytes1os = new ByteArrayOutputStream();
+- LZ4BlockOutputStream out1 = new LZ4BlockOutputStream(bytes1os);
+- out1.write(testBytes1);
+- out1.close();
+-
+- ByteArrayOutputStream bytes2os = new ByteArrayOutputStream();
+- LZ4BlockOutputStream out2 = new LZ4BlockOutputStream(bytes2os);
+- out2.write(testBytes2);
+- out2.close();
+-
+- byte[] bytes1 = bytes1os.toByteArray();
+- byte[] bytes2 = bytes2os.toByteArray();
+- byte[] concatenatedBytes = new byte[bytes1.length + bytes2.length];
+- System.arraycopy(bytes1, 0, concatenatedBytes, 0, bytes1.length);
+- System.arraycopy(bytes2, 0, concatenatedBytes, bytes1.length, bytes2.length);
+-
+- // In a default behaviour, we can read the first block of the concatenated bytes
only
+- LZ4BlockInputStream in1 = new LZ4BlockInputStream(new
ByteArrayInputStream(concatenatedBytes));
+- byte[] actual1 = new byte[128];
+- assertEquals(64, readFully(in1, actual1));
+- assertEquals(-1, in1.read());
+- in1.close();
+-
+- // Check if we can read concatenated byte stream
+- LZ4BlockInputStream in2 = new LZ4BlockInputStream(new
ByteArrayInputStream(concatenatedBytes), false);
+- byte[] actual2 = new byte[128];
+- assertEquals(128, readFully(in2, actual2));
+- assertEquals(-1, in2.read());
+- in2.close();
+-
+- assertArrayEquals(expected, actual2);
+- }
+-}
+diff --git a/src/test/net/jpountz/lz4/LZ4Test.java
b/src/test/net/jpountz/lz4/LZ4Test.java
+deleted file mode 100644
+index 161899c..0000000
+--- a/src/test/net/jpountz/lz4/LZ4Test.java
++++ /dev/null
+@@ -1,562 +0,0 @@
+-package net.jpountz.lz4;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import static net.jpountz.lz4.Instances.COMPRESSORS;
+-import static net.jpountz.lz4.Instances.FAST_DECOMPRESSORS;
+-import static net.jpountz.lz4.Instances.SAFE_DECOMPRESSORS;
+-
+-import java.io.ByteArrayOutputStream;
+-import java.io.IOException;
+-import java.nio.ByteBuffer;
+-import java.nio.ReadOnlyBufferException;
+-import java.util.Arrays;
+-import java.io.File;
+-import java.io.FilenameFilter;
+-
+-import org.junit.Test;
+-import static org.junit.Assert.*;
+-
+-import com.carrotsearch.randomizedtesting.annotations.Repeat;
+-
+-public class LZ4Test extends AbstractLZ4Test {
+-
+- @Test
+- public void testLockFileOfTemporaryNativeLibrary() {
+- // Load the native library
+- LZ4JNI.LZ4_compressBound(100);
+- String tempFolder = new
File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
+- File tempDir = new File(new
File(System.getProperty("java.io.tmpdir")).getAbsolutePath());
+- if (!System.getProperty("os.name").contains("Windows")) {
+- // A temporary library must be accompanied by a lock file.
+- // On Windows, JVM does not remove a temporary library on exit.
+- // This means on Windows, there might be a temporary library
+- // that is not accompanied by a lock file when there was
+- // a Java process using lz4-java that was running concurrently
+- // to this test process.
+- File[] tempLibFiles = tempDir.listFiles(new FilenameFilter() {
+- public boolean accept(File dir, String name) {
+- return name.startsWith("liblz4-java-") &&
!name.endsWith(".lck");
+- }
+- });
+- if (tempLibFiles != null) {
+- for (File tempLibFile : tempLibFiles) {
+- File lckFile = new File(tempLibFile.getAbsolutePath() + ".lck");
+- assertTrue(tempLibFile.getAbsolutePath(), lckFile.exists());
+- }
+- }
+- }
+- // A lock file must be accompanied by a temporary library.
+- File[] tempLockFiles = tempDir.listFiles(new FilenameFilter() {
+- public boolean accept(File dir, String name) {
+- return name.startsWith("liblz4-java-") &&
name.endsWith(".lck");
+- }
+- });
+- if (tempLockFiles != null) {
+- for (File tempLockFile : tempLockFiles) {
+- String tempLockFilePath = tempLockFile.getAbsolutePath();
+- File libFile = new File(tempLockFilePath.substring(0, tempLockFilePath.length() - 4));
+- assertTrue(tempLockFilePath, libFile.exists());
+- }
+- }
+- }
+-
+- @Test
+- @Repeat(iterations=50)
+- public void testMaxCompressedLength() {
+- final int len = randomBoolean() ? randomInt(16) : randomInt(1 << 30);
+- for (LZ4Compressor compressor : COMPRESSORS) {
+- assertEquals(LZ4JNI.LZ4_compressBound(len), compressor.maxCompressedLength(len));
+- }
+- }
+-
+- private static byte[] getCompressedWorstCase(byte[] decompressed) {
+- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+- int len = decompressed.length;
+- if (len >= LZ4Constants.RUN_MASK) {
+- baos.write(LZ4Constants.RUN_MASK << LZ4Constants.ML_BITS);
+- len -= LZ4Constants.RUN_MASK;
+- }
+- while (len >= 255) {
+- baos.write(255);
+- len -= 255;
+- }
+- baos.write(len);
+- try {
+- baos.write(decompressed);
+- } catch (IOException e) {
+- throw new AssertionError();
+- }
+- return baos.toByteArray();
+- }
+-
+- @Test
+- public void testEmpty() {
+- testRoundTrip(new byte[0]);
+- }
+-
+- public void testUncompressWorstCase(LZ4FastDecompressor decompressor) {
+- final int len = randomInt(100 * 1024);
+- final int max = randomIntBetween(1, 255);
+- byte[] decompressed = randomArray(len, max);
+- byte[] compressed = getCompressedWorstCase(decompressed);
+- byte[] restored = new byte[decompressed.length];
+- int cpLen = decompressor.decompress(compressed, 0, restored, 0,
decompressed.length);
+- assertEquals(compressed.length, cpLen);
+- assertArrayEquals(decompressed, restored);
+- }
+-
+- @Test
+- public void testUncompressWorstCase() {
+- for (LZ4FastDecompressor decompressor : FAST_DECOMPRESSORS) {
+- testUncompressWorstCase(decompressor);
+- }
+- }
+-
+- public void testUncompressWorstCase(LZ4SafeDecompressor decompressor) {
+- final int len = randomInt(100 * 1024);
+- final int max = randomIntBetween(1, 256);
+- byte[] decompressed = randomArray(len, max);
+- byte[] compressed = getCompressedWorstCase(decompressed);
+- byte[] restored = new byte[decompressed.length];
+- int uncpLen = decompressor.decompress(compressed, 0, compressed.length, restored,
0);
+- assertEquals(decompressed.length, uncpLen);
+- assertArrayEquals(decompressed, restored);
+- }
+-
+- @Test
+- public void testUncompressSafeWorstCase() {
+- for (LZ4SafeDecompressor decompressor : SAFE_DECOMPRESSORS) {
+- testUncompressWorstCase(decompressor);
+- }
+- }
+-
+- public void testRoundTrip(byte[] data, int off, int len,
+- LZ4Compressor compressor,
+- LZ4FastDecompressor decompressor,
+- LZ4SafeDecompressor decompressor2) {
+- for (Tester<?> tester : Arrays.asList(Tester.BYTE_ARRAY, Tester.BYTE_BUFFER,
Tester.BYTE_ARRAY_WITH_LENGTH, Tester.BYTE_BUFFER_WITH_LENGTH)) {
+- testRoundTrip(tester, data, off, len, compressor, decompressor, decompressor2);
+- }
+- }
+-
+- public <T> void testRoundTrip(
+- Tester<T> tester,
+- byte[] data, int off, int len,
+- LZ4Compressor compressor,
+- LZ4FastDecompressor decompressor,
+- LZ4SafeDecompressor decompressor2) {
+- final int maxCompressedLength = tester.maxCompressedLength(len);
+- // "maxCompressedLength + 1" for the over-estimated compressed length test
below
+- final T compressed = tester.allocate(maxCompressedLength + 1);
+- final int compressedLen = tester.compress(compressor,
+- tester.copyOf(data), off, len,
+- compressed, 0, maxCompressedLength);
+-
+- // test decompression
+- final T restored = tester.allocate(len);
+- assertEquals(compressedLen, tester.decompress(decompressor, compressed, 0, restored,
0, len));
+- assertArrayEquals(Arrays.copyOfRange(data, off, off + len), tester.copyOf(restored,
0, len));
+-
+- // make sure it fails if the compression dest is not large enough
+- tester.fill(restored, randomByte());
+- final T compressed2 = tester.allocate(compressedLen-1);
+- try {
+- final int compressedLen2 = tester.compress(compressor,
+- tester.copyOf(data), off, len,
+- compressed2, 0, compressedLen - 1);
+- // Compression can succeed even with the smaller dest
+- // because the compressor is allowed to return different compression results
+- // even when it is invoked with the same input data.
+- // In this case, just make sure the compressed data can be successfully
decompressed.
+- assertEquals(compressedLen2, tester.decompress(decompressor, compressed2, 0,
restored, 0, len));
+- assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
+- } catch (LZ4Exception e) {
+- // OK
+- }
+-
+- if (tester != Tester.BYTE_ARRAY_WITH_LENGTH && tester !=
Tester.BYTE_BUFFER_WITH_LENGTH) {
+- if (len > 0) {
+- // decompression dest is too small
+- try {
+- tester.decompress(decompressor, compressed, 0, restored, 0, len - 1);
+- fail();
+- } catch (LZ4Exception e) {
+- // OK
+- }
+- }
+-
+- // decompression dest is too large
+- final T restored2 = tester.allocate(len+1);
+- try {
+- final int cpLen = tester.decompress(decompressor, compressed, 0, restored2, 0, len +
1);
+- fail("compressedLen=" + cpLen);
+- } catch (LZ4Exception e) {
+- // OK
+- }
+-
+- // try decompression when only the size of the compressed buffer is known
+- if (len > 0) {
+- tester.fill(restored, randomByte());
+- assertEquals(len, tester.decompress(decompressor2, compressed, 0, compressedLen,
restored, 0, len));
+- assertArrayEquals(Arrays.copyOfRange(data, off, off + len), tester.copyOf(restored, 0,
len));
+- tester.fill(restored, randomByte());
+- } else {
+- assertEquals(0, tester.decompress(decompressor2, compressed, 0, compressedLen,
tester.allocate(1), 0, 1));
+- }
+-
+- // over-estimated compressed length
+- try {
+- final int decompressedLen = tester.decompress(decompressor2, compressed, 0,
compressedLen + 1, tester.allocate(len + 100), 0, len + 100);
+- fail("decompressedLen=" + decompressedLen);
+- } catch (LZ4Exception e) {
+- // OK
+- }
+-
+- // under-estimated compressed length
+- try {
+- final int decompressedLen = tester.decompress(decompressor2, compressed, 0,
compressedLen - 1, tester.allocate(len + 100), 0, len + 100);
+- if (!(decompressor2 instanceof LZ4JNISafeDecompressor)) {
+- fail("decompressedLen=" + decompressedLen);
+- }
+- } catch (LZ4Exception e) {
+- // OK
+- }
+- }
+- }
+-
+- public void testRoundTrip(byte[] data, int off, int len, LZ4Factory compressorFactory,
LZ4Factory decompressorFactory) {
+- for (LZ4Compressor compressor : Arrays.asList(
+- compressorFactory.fastCompressor(), compressorFactory.highCompressor())) {
+- testRoundTrip(data, off, len, compressor, decompressorFactory.fastDecompressor(),
decompressorFactory.safeDecompressor());
+- }
+- }
+-
+- public void testRoundTrip(byte[] data, int off, int len) {
+- for (LZ4Factory compressorFactory : Arrays.asList(
+- LZ4Factory.nativeInstance(),
+- LZ4Factory.unsafeInstance(),
+- LZ4Factory.safeInstance())) {
+- for (LZ4Factory decompressorFactory : Arrays.asList(
+- LZ4Factory.nativeInstance(),
+- LZ4Factory.unsafeInstance(),
+- LZ4Factory.safeInstance())) {
+- testRoundTrip(data, off, len, compressorFactory, decompressorFactory);
+- }
+- }
+- }
+-
+- public void testRoundTrip(byte[] data) {
+- testRoundTrip(data, 0, data.length);
+- }
+-
+- public void testRoundTrip(String resource) throws IOException {
+- final byte[] data = readResource(resource);
+- testRoundTrip(data);
+- }
+-
+- @Test
+- public void testRoundtripGeo() throws IOException {
+- testRoundTrip("/calgary/geo");
+- }
+-
+- @Test
+- public void testRoundtripBook1() throws IOException {
+- testRoundTrip("/calgary/book1");
+- }
+-
+- @Test
+- public void testRoundtripPic() throws IOException {
+- testRoundTrip("/calgary/pic");
+- }
+-
+- @Test
+- public void testNullMatchDec() {
+- // 1 literal, 4 matchs with matchDec=0, 8 literals
+- final byte[] invalid = new byte[] { 16, 42, 0, 0, (byte) 128, 42, 42, 42, 42, 42,
42, 42, 42 };
+- // decompression should neither throw an exception nor loop indefinitely
+- for (LZ4FastDecompressor decompressor : FAST_DECOMPRESSORS) {
+- decompressor.decompress(invalid, 0, new byte[13], 0, 13);
+- }
+- for (LZ4SafeDecompressor decompressor : SAFE_DECOMPRESSORS) {
+- decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
+- }
+- }
+-
+- @Test
+- public void testEndsWithMatch() {
+- // 6 literals, 4 matchs
+- final byte[] invalid = new byte[] { 96, 42, 43, 44, 45, 46, 47, 5, 0 };
+- final int decompressedLength = 10;
+-
+- for (LZ4FastDecompressor decompressor : FAST_DECOMPRESSORS) {
+- try {
+- // it is invalid to end with a match, should be at least 5 literals
+- decompressor.decompress(invalid, 0, new byte[decompressedLength], 0,
decompressedLength);
+- assertTrue(decompressor.toString(), false);
+- } catch (LZ4Exception e) {
+- // OK
+- }
+- }
+-
+- for (LZ4SafeDecompressor decompressor : SAFE_DECOMPRESSORS) {
+- try {
+- // it is invalid to end with a match, should be at least 5 literals
+- decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
+- assertTrue(false);
+- } catch (LZ4Exception e) {
+- // OK
+- }
+- }
+- }
+-
+- @Test
+- public void testEndsWithLessThan5Literals() {
+- // 6 literals, 4 matchs
+- final byte[] invalidBase = new byte[] { 96, 42, 43, 44, 45, 46, 47, 5, 0 };
+-
+- for (int i = 1; i < 5; ++i) {
+- final byte[] invalid = Arrays.copyOf(invalidBase, invalidBase.length + 1 + i);
+- invalid[invalidBase.length] = (byte) (i << 4); // i literals at the end
+-
+- for (LZ4FastDecompressor decompressor : FAST_DECOMPRESSORS) {
+- try {
+- // it is invalid to end with a match, should be at least 5 literals
+- decompressor.decompress(invalid, 0, new byte[20], 0, 20);
+- assertTrue(decompressor.toString(), false);
+- } catch (LZ4Exception e) {
+- // OK
+- }
+- }
+-
+- for (LZ4SafeDecompressor decompressor : SAFE_DECOMPRESSORS) {
+- try {
+- // it is invalid to end with a match, should be at least 5 literals
+- decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
+- assertTrue(false);
+- } catch (LZ4Exception e) {
+- // OK
+- }
+- }
+- }
+- }
+-
+- @Test
+- public void testWriteToReadOnlyBuffer() {
+- for (LZ4Compressor compressor : COMPRESSORS) {
+- ByteBuffer in = Tester.BYTE_BUFFER.copyOf(new byte[] {2, 3});
+- ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
+- try {
+- compressor.compress(in, out);
+- fail();
+- } catch (ReadOnlyBufferException e) {
+- // ok
+- }
+- }
+- for (LZ4SafeDecompressor decompressor : SAFE_DECOMPRESSORS) {
+- ByteBuffer in = Tester.BYTE_BUFFER.copyOf(COMPRESSORS[0].compress(new byte[] {2,
3}));
+- ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
+- try {
+- decompressor.decompress(in, out);
+- fail();
+- } catch (ReadOnlyBufferException e) {
+- // ok
+- }
+- }
+- for (LZ4FastDecompressor decompressor : FAST_DECOMPRESSORS) {
+- ByteBuffer in = Tester.BYTE_BUFFER.copyOf(COMPRESSORS[0].compress(new byte[] {2,
3}));
+- ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
+- out.limit(2);
+- try {
+- decompressor.decompress(in, out);
+- fail();
+- } catch (ReadOnlyBufferException e) {
+- // ok
+- }
+- }
+- }
+-
+- @Test
+- @Repeat(iterations=5)
+- public void testAllEqual() {
+- final int len = randomBoolean() ? randomInt(20) : randomInt(100000);
+- final byte[] buf = new byte[len];
+- Arrays.fill(buf, randomByte());
+- testRoundTrip(buf);
+- }
+-
+- @Test
+- public void testMaxDistance() {
+- final int len = randomIntBetween(1 << 17, 1 << 18);
+- final int off = randomInt(len - (1 << 16) - (1 << 15));
+- final byte[] buf = new byte[len];
+- for (int i = 0; i < (1 << 15); ++i) {
+- buf[off + i] = randomByte();
+- }
+- System.arraycopy(buf, off, buf, off + 65535, 1 << 15);
+- testRoundTrip(buf);
+- }
+-
+- @Test
+- @Repeat(iterations=10)
+- public void testRandomData() {
+- final int n = randomIntBetween(1, 15);
+- final int off = randomInt(1000);
+- final int len = randomBoolean() ? randomInt(1 << 16) : randomInt(1 <<
20);
+- final byte[] data = randomArray(off + len + randomInt(100), n);
+- testRoundTrip(data, off, len);
+- }
+-
+- @Test
+- //
https://github.com/jpountz/lz4-java/issues/12
+- public void testRoundtripIssue12() {
+- byte[] data = new byte[]{
+- 14, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 72, 14, 72, 14, 85, 3, 72, 14, 72, 14,
72, 14, 72, 14, 72, 14, 72, 14, 85, 3, 72,
+- 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14,
50, 64, 0, 46, -1, 0, 0, 0, 29, 3, 85,
+- 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68,
-113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3,
+- 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0,
68, -113, 0, 2, 3, -97, 6, 0, 68, -113,
+- 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0,
68, -113, 0, 2, 3, -97, 6, 0, 68, -113,
+- 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 50, 64, 0, 47,
-105, 0, 0, 0, 30, 3, -97, 6, 0, 68, -113,
+- 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85,
8, -113, 0, 68, -97, 3, 0, 2, 3, 85,
+- 8, -113, 0, 68, -97, 3, 0, 2, -97, 6, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2,
3, -97, 6, 0, 68, -113, 0, 2, 3, -97,
+- 6, 0, 68, -113, 0, 120, 64, 0, 48, 4, 0, 0, 0, 31, 34, 72, 29, 72, 37, 72, 35,
72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72,
+- 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72,
41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72,
+- 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72,
40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72,
+- 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72,
31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72,
+- 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72,
26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72,
+- 41, 72, 32, 72, 18, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
+- 0, 39, 24, 32, 34, 124, 0, 120, 64, 0, 48, 80, 0, 0, 0, 31, 30, 72, 22, 72, 31,
72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72,
+- 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72,
26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72,
+- 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72,
37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72,
+- 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72,
36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72,
+- 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72,
20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72,
+- 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72,
22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72,
+- 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72,
38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72,
+- 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72,
29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72,
+- 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72,
27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72,
+- 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72,
46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72,
+- 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72,
30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72,
+- 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72,
39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72,
+- 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 50,
64, 0, 49, 20, 0, 0, 0, 32, 3, -97, 6, 0,
+- 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0,
2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97,
+- 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68,
-113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2,
+- 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68,
-113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2,
+- 3, -97, 6, 0, 50, 64, 0, 50, 53, 0, 0, 0, 34, 3, -97, 6, 0, 68, -113, 0, 2, 3,
85, 8, -113, 0, 68, -113, 0, 2, 3, -97,
+- 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113,
0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3,
+- -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0,
68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97,
+- 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3,
85, 8, -113, 0, 68, -97, 3, 0, 2, 3,
+- 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0,
68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0,
+- 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3,
85, 8, -113, 0, 68, -97, 3, 0, 2, 3,
+- -97, 6, 0, 50, 64, 0, 51, 85, 0, 0, 0, 36, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2,
3, -97, 6, 0, 68, -113, 0, 2, 3, -97,
+- 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0,
2, -97, 5, 0, 2, 3, 85, 8, -113, 0, 68,
+- -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3,
-97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0,
+- 68, -113, 0, 2, 3, -97, 6, 0, 50, -64, 0, 51, -45, 0, 0, 0, 37, 68, -113, 0, 2,
3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6,
+- 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2,
3, 85, 8, -113, 0, 68, -113, 0, 2, 3, -97,
+- 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0,
68, -97, 3, 0, 120, 64, 0, 52, -88, 0, 0,
+- 0, 39, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13,
85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72,
+- 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5,
72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85,
+- 5, 72, 13, 85, 5, 72, 13, 72, 13, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13,
72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85,
+- 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5,
72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85,
+- 5, 72, 13, 85, 5, 72, 13, 72, 13, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13,
85, 5, 72, 13, 72, 13, 85, 5, 72, 13, 72,
+- 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, -19, -24, -101, -35
+- };
+- testRoundTrip(data, 9, data.length - 9);
+- }
+-
+- private static void assertCompressedArrayEquals(String message, byte[] expected,
byte[] actual) {
+- int off = 0;
+- int decompressedOff = 0;
+- while (true) {
+- if (off == expected.length) {
+- break;
+- }
+- final Sequence sequence1 = readSequence(expected, off);
+- final Sequence sequence2 = readSequence(actual, off);
+- assertEquals(message + ", off=" + off + ", decompressedOff=" +
decompressedOff, sequence1, sequence2);
+- off += sequence1.length;
+- decompressedOff += sequence1.literalLen + sequence1.matchLen;
+- }
+- }
+-
+- private static Sequence readSequence(byte[] buf, int off) {
+- final int start = off;
+- final int token = buf[off++] & 0xFF;
+- int literalLen = token >>> 4;
+- if (literalLen >= 0x0F) {
+- int len;
+- while ((len = buf[off++] & 0xFF) == 0xFF) {
+- literalLen += 0xFF;
+- }
+- literalLen += len;
+- }
+- off += literalLen;
+- if (off == buf.length) {
+- return new Sequence(literalLen, -1, -1, off - start);
+- }
+- int matchDec = (buf[off++] & 0xFF) | ((buf[off++] & 0xFF) << 8);
+- int matchLen = token & 0x0F;
+- if (matchLen >= 0x0F) {
+- int len;
+- while ((len = buf[off++] & 0xFF) == 0xFF) {
+- matchLen += 0xFF;
+- }
+- matchLen += len;
+- }
+- matchLen += 4;
+- return new Sequence(literalLen, matchDec, matchLen, off - start);
+- }
+-
+- private static class Sequence {
+- final int literalLen, matchDec, matchLen, length;
+-
+- public Sequence(int literalLen, int matchDec, int matchLen, int length) {
+- this.literalLen = literalLen;
+- this.matchDec = matchDec;
+- this.matchLen = matchLen;
+- this.length = length;
+- }
+-
+- @Override
+- public String toString() {
+- return "Sequence [literalLen=" + literalLen + ", matchDec=" +
matchDec
+- + ", matchLen=" + matchLen + "]";
+- }
+-
+- @Override
+- public int hashCode() {
+- return 42;
+- }
+-
+- @Override
+- public boolean equals(Object obj) {
+- if (this == obj)
+- return true;
+- if (obj == null)
+- return false;
+- if (getClass() != obj.getClass())
+- return false;
+- Sequence other = (Sequence) obj;
+- if (literalLen != other.literalLen)
+- return false;
+- if (matchDec != other.matchDec)
+- return false;
+- if (matchLen != other.matchLen)
+- return false;
+- return true;
+- }
+-
+- }
+-
+-}
+diff --git a/src/test/net/jpountz/xxhash/XXHash32Test.java
b/src/test/net/jpountz/xxhash/XXHash32Test.java
+deleted file mode 100644
+index 98c9436..0000000
+--- a/src/test/net/jpountz/xxhash/XXHash32Test.java
++++ /dev/null
+@@ -1,189 +0,0 @@
+-package net.jpountz.xxhash;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import java.nio.ByteBuffer;
+-
+-import net.jpountz.lz4.AbstractLZ4Test;
+-import net.jpountz.util.SafeUtils;
+-
+-import org.junit.Test;
+-import static org.junit.Assert.*;
+-
+-import com.carrotsearch.randomizedtesting.annotations.Repeat;
+-
+-public class XXHash32Test extends AbstractLZ4Test {
+-
+- private static abstract class StreamingXXHash32Adapter extends XXHash32 {
+-
+- protected abstract StreamingXXHash32 streamingHash(int seed);
+-
+- @Override
+- public int hash(byte[] buf, int off, int len, int seed) {
+- SafeUtils.checkRange(buf, off, len);
+- int originalOff = off;
+- int remainingPasses = randomInt(5);
+- StreamingXXHash32 h = streamingHash(seed);
+- final int end = off + len;
+- while (off < end) {
+- final int l = randomIntBetween(off, end) - off;
+- h.update(buf, off, l);
+- off += l;
+- if (remainingPasses > 0 && randomInt(5) == 0) {
+- h.reset();
+- --remainingPasses;
+- off = originalOff;
+- }
+- if (randomBoolean()) {
+- h.getValue();
+- }
+- }
+- return h.getValue();
+- }
+-
+- @Override
+- public int hash(ByteBuffer buf, int off, int len, int seed) {
+- byte[] bytes = new byte[len];
+- int originalPosition = buf.position();
+- try {
+- buf.position(off);
+- buf.get(bytes, 0, len);
+- return hash(bytes, 0, len, seed);
+- } finally {
+- buf.position(originalPosition);
+- }
+- }
+-
+- public String toString() {
+- return streamingHash(0).toString();
+- }
+-
+- }
+-
+- private static XXHash32[] INSTANCES = new XXHash32[] {
+- XXHashFactory.nativeInstance().hash32(),
+- XXHashFactory.unsafeInstance().hash32(),
+- XXHashFactory.safeInstance().hash32(),
+- new StreamingXXHash32Adapter() {
+- protected StreamingXXHash32 streamingHash(int seed) {
+- return XXHashFactory.nativeInstance().newStreamingHash32(seed);
+- }
+- },
+- new StreamingXXHash32Adapter() {
+- protected StreamingXXHash32 streamingHash(int seed) {
+- return XXHashFactory.unsafeInstance().newStreamingHash32(seed);
+- }
+- },
+- new StreamingXXHash32Adapter() {
+- protected StreamingXXHash32 streamingHash(int seed) {
+- return XXHashFactory.safeInstance().newStreamingHash32(seed);
+- }
+- }
+- };
+-
+- @Test
+- public void testEmpty() {
+- final int seed = randomInt();
+- for (XXHash32 xxHash : INSTANCES) {
+- xxHash.hash(new byte[0], 0, 0, seed);
+- xxHash.hash(copyOf(new byte[0], 0, 0), 0, 0, seed);
+- }
+- }
+-
+- @Test
+- @Repeat(iterations = 20)
+- public void testAIOOBE() {
+- final int seed = randomInt();
+- final int max = randomBoolean() ? 32 : 1000;
+- final int bufLen = randomIntBetween(1, max);
+- final byte[] buf = randomArray(bufLen, 256);
+- final int off = randomInt(buf.length - 1);
+- final int len = randomInt(buf.length - off);
+- for (XXHash32 xxHash : INSTANCES) {
+- xxHash.hash(buf, off, len, seed);
+- xxHash.hash(copyOf(buf, off, len), off, len, seed);
+- }
+- }
+-
+- @Test
+- @Repeat(iterations=40)
+- public void testInstances() {
+- final int maxLenLog = randomInt(20);
+- final int bufLen = randomInt(1 << maxLenLog);
+- byte[] buf = randomArray(bufLen, 256);
+- final int seed = randomInt();
+- final int off = randomIntBetween(0, Math.max(0, bufLen - 1));
+- final int len = randomIntBetween(0, bufLen - off);
+-
+- final int ref = XXHashFactory.nativeInstance().hash32().hash(buf, off, len, seed);
+- for (XXHash32 hash : INSTANCES) {
+- final int h = hash.hash(buf, off, len, seed);
+- assertEquals(hash.toString(), ref, h);
+- final ByteBuffer copy = copyOf(buf, off, len);
+- final int h2 = hash.hash(copy, off, len, seed);
+- assertEquals(off, copy.position());
+- assertEquals(len, copy.remaining());
+- assertEquals(hash.toString(), ref, h2);
+- }
+- }
+-
+- @Test
+- public void test4GB() {
+- byte[] bytes = new byte[randomIntBetween(1 << 22, 1 << 26)];
+- for (int i = 0; i < bytes.length; ++i) {
+- bytes[i] = randomByte();
+- }
+- final int off = randomInt(5);
+- final int len = randomIntBetween(bytes.length - off - 1024, bytes.length - off);
+- long totalLen = 0;
+- final int seed = randomInt();
+- StreamingXXHash32 hash1 = XXHashFactory.nativeInstance().newStreamingHash32(seed);
+- StreamingXXHash32 hash2 = XXHashFactory.unsafeInstance().newStreamingHash32(seed);
+- StreamingXXHash32 hash3 = XXHashFactory.safeInstance().newStreamingHash32(seed);
+- while (totalLen < (1L << 33)) {
+- hash1.update(bytes, off, len);
+- hash2.update(bytes, off, len);
+- hash3.update(bytes, off, len);
+- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
+- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
+- totalLen += len;
+- }
+- }
+-
+- @Test
+- public void testClose() {
+- StreamingXXHash32 hash =
XXHashFactory.nativeInstance().newStreamingHash32(randomInt());
+- hash.close();
+- hash.close();
+- try {
+- hash.getValue();
+- assertTrue(hash.toString(), false);
+- } catch (AssertionError e) {
+- // OK
+- }
+- try {
+- hash.update(null, 0, 0);
+- assertTrue(hash.toString(), false);
+- } catch (AssertionError e) {
+- // OK
+- }
+- try {
+- hash.reset();
+- assertTrue(hash.toString(), false);
+- } catch (AssertionError e) {
+- // OK
+- }
+- }
+-}
+diff --git a/src/test/net/jpountz/xxhash/XXHash64Test.java
b/src/test/net/jpountz/xxhash/XXHash64Test.java
+deleted file mode 100644
+index dadbeda..0000000
+--- a/src/test/net/jpountz/xxhash/XXHash64Test.java
++++ /dev/null
+@@ -1,194 +0,0 @@
+-package net.jpountz.xxhash;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import java.nio.ByteBuffer;
+-
+-import net.jpountz.lz4.AbstractLZ4Test;
+-import net.jpountz.util.SafeUtils;
+-
+-import org.junit.Test;
+-import static org.junit.Assert.*;
+-
+-import com.carrotsearch.randomizedtesting.annotations.Repeat;
+-
+-public class XXHash64Test extends AbstractLZ4Test {
+-
+- private static abstract class StreamingXXHash64Adapter extends XXHash64 {
+-
+- protected abstract StreamingXXHash64 streamingHash(long seed);
+-
+- @Override
+- public long hash(byte[] buf, int off, int len, long seed) {
+- SafeUtils.checkRange(buf, off, len);
+- int originalOff = off;
+- int remainingPasses = randomInt(5);
+- StreamingXXHash64 h = streamingHash(seed);
+- final int end = off + len;
+- while (off < end) {
+- final int l = randomIntBetween(off, end) - off;
+- h.update(buf, off, l);
+- off += l;
+- if (remainingPasses > 0 && randomInt(5) == 0) {
+- h.reset();
+- --remainingPasses;
+- off = originalOff;
+- }
+- if (randomBoolean()) {
+- h.getValue();
+- }
+- }
+- return h.getValue();
+- }
+-
+- @Override
+- public long hash(ByteBuffer buf, int off, int len, long seed) {
+- byte[] bytes = new byte[len];
+- int originalPosition = buf.position();
+- try {
+- buf.position(off);
+- buf.get(bytes, 0, len);
+- return hash(bytes, 0, len, seed);
+- } finally {
+- buf.position(originalPosition);
+- }
+- }
+-
+- public String toString() {
+- return streamingHash(0).toString();
+- }
+-
+- }
+-
+- private static XXHash64[] INSTANCES = new XXHash64[] {
+- XXHashFactory.nativeInstance().hash64(),
+- XXHashFactory.unsafeInstance().hash64(),
+- XXHashFactory.safeInstance().hash64(),
+- new StreamingXXHash64Adapter() {
+- protected StreamingXXHash64 streamingHash(long seed) {
+- return XXHashFactory.nativeInstance().newStreamingHash64(seed);
+- }
+- },
+- new StreamingXXHash64Adapter() {
+- protected StreamingXXHash64 streamingHash(long seed) {
+- return XXHashFactory.unsafeInstance().newStreamingHash64(seed);
+- }
+- },
+- new StreamingXXHash64Adapter() {
+- protected StreamingXXHash64 streamingHash(long seed) {
+- return XXHashFactory.safeInstance().newStreamingHash64(seed);
+- }
+- }
+- };
+-
+- @Test
+- public void testEmpty() {
+- final long seed = randomLong();
+- for (XXHash64 xxHash : INSTANCES) {
+- xxHash.hash(new byte[0], 0, 0, seed);
+- xxHash.hash(copyOf(new byte[0], 0, 0), 0, 0, seed);
+- }
+- }
+-
+- @Test
+- @Repeat(iterations = 20)
+- public void testAIOOBE() {
+- final long seed = randomLong();
+- final int max = randomBoolean() ? 64 : 1000;
+- final int bufLen = randomIntBetween(1, max);
+- final byte[] buf = new byte[bufLen];
+- for (int i = 0; i < buf.length; ++i) {
+- buf[i] = randomByte();
+- }
+- final int off = randomInt(buf.length - 1);
+- final int len = randomInt(buf.length - off);
+- for (XXHash64 xxHash : INSTANCES) {
+- xxHash.hash(buf, off, len, seed);
+- }
+- }
+-
+- @Test
+- @Repeat(iterations=40)
+- public void testInstances() {
+- final int maxLenLog = randomInt(20);
+- final int bufLen = randomInt(1 << maxLenLog);
+- byte[] buf = new byte[bufLen];
+- for (int i = 0; i < bufLen; ++i) {
+- buf[i] = randomByte();
+- }
+- final long seed = randomLong();
+- final int off = randomIntBetween(0, Math.max(0, bufLen - 1));
+- final int len = randomIntBetween(0, bufLen - off);
+-
+- final long ref = XXHashFactory.nativeInstance().hash64().hash(buf, off, len, seed);
+- for (XXHash64 hash : INSTANCES) {
+- final long h = hash.hash(buf, off, len, seed);
+- assertEquals(hash.toString(), ref, h);
+- final ByteBuffer copy = copyOf(buf, off, len);
+- final long h2 = hash.hash(copy, off, len, seed);
+- assertEquals(off, copy.position());
+- assertEquals(len, copy.remaining());
+- assertEquals(hash.toString(), ref, h2);
+- }
+- }
+-
+- @Test
+- public void test4GB() {
+- byte[] bytes = new byte[randomIntBetween(1 << 22, 1 << 26)];
+- for (int i = 0; i < bytes.length; ++i) {
+- bytes[i] = randomByte();
+- }
+- final int off = randomInt(5);
+- final int len = randomIntBetween(bytes.length - off - 1024, bytes.length - off);
+- long totalLen = 0;
+- final long seed = randomLong();
+- StreamingXXHash64 hash1 = XXHashFactory.nativeInstance().newStreamingHash64(seed);
+- StreamingXXHash64 hash2 = XXHashFactory.unsafeInstance().newStreamingHash64(seed);
+- StreamingXXHash64 hash3 = XXHashFactory.safeInstance().newStreamingHash64(seed);
+- while (totalLen < (1L << 33)) {
+- hash1.update(bytes, off, len);
+- hash2.update(bytes, off, len);
+- hash3.update(bytes, off, len);
+- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
+- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
+- totalLen += len;
+- }
+- }
+-
+- @Test
+- public void testClose() {
+- StreamingXXHash64 hash =
XXHashFactory.nativeInstance().newStreamingHash64(randomInt());
+- hash.close();
+- hash.close();
+- try {
+- hash.getValue();
+- assertTrue(hash.toString(), false);
+- } catch (AssertionError e) {
+- // OK
+- }
+- try {
+- hash.update(null, 0, 0);
+- assertTrue(hash.toString(), false);
+- } catch (AssertionError e) {
+- // OK
+- }
+- try {
+- hash.reset();
+- assertTrue(hash.toString(), false);
+- } catch (AssertionError e) {
+- // OK
+- }
+- }
+-}
diff --git a/lz4-java.spec b/lz4-java.spec
index 0a94e93..c7f85be 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -3,28 +3,29 @@
Name: lz4-java
Version: 1.7.1
-Release: 8%{?dist}
+Release: 9%{?dist}
Summary: LZ4 compression for Java
License: ASL 2.0
+# GPLv2+ and BSD for lz4 and xxhash libs that are shared in liblz4-java.so
URL:
https://github.com/lz4/lz4-java
Source0:
https://github.com/lz4/lz4-java/archive/%{version}.tar.gz
-# lz4-java tests require randomizedtesting, which is not currently
-# shipped or maintained in Fedora.
-Patch0: 0-remove-tests.patch
# lz4-java v1.3.0 introduced usage of sun.misc.Unsafe, which would later become
# depricated in jdk 9 and kept as an unexposed API in later jdk releases.
# lz4-java optionally uses Unsafe to achieve faster compression and decompression,
# however it's implementation is not critical to functionality, and can be removed.
-Patch1: 1-remove-unsafe.patch
+Patch0: 0-remove-unsafe.patch
# After updating mvel to version 2.4.10, MVEL generated classes have formatting issues
where
# code after comments are not being formatted with new lines. As a result, including
comments
# in the templates results in classes with invalid code following the first comment.
# This patch simply removes comments from the templates so the classes can be generated
as expected.
# Related bug:
https://github.com/mvel/mvel/issues/152
-Patch2: 2-remove-comments-from-templates.patch
+Patch1: 1-remove-comments-from-templates.patch
# Adds a simple makefile to be run in-place of the cpptasks in the build.xml
-Patch3: 3-remove-cpptasks.patch
+Patch2: 2-remove-cpptasks.patch
+# some lz4-java tests require randomizedtesting, which is not currently
+# shipped or maintained in Fedora; remove those and use system ant-junit to run
applicable tests
+Patch3: 3-remove-randomizedtesting-tests.patch
# Build tools
BuildRequires: apache-parent
@@ -35,6 +36,7 @@ BuildRequires: gcc
BuildRequires: ivy-local
BuildRequires: java-devel
BuildRequires: javapackages-local
+BuildRequires: lz4
BuildRequires: lz4-devel
BuildRequires: mvel
BuildRequires: objectweb-asm
@@ -90,11 +92,10 @@ find -name '*.so' -print -delete
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
%endif
-ant -Divy.mode=local -Divy.revision=1.7.1 -Divy.pom.version=1.7.1 jar docs makepom
+ant -Divy.mode=local -Divy.revision=1.7.1 -Divy.pom.version=1.7.1 jar test docs makepom
bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version %{version}
dist/lz4-java.jar
%install
-%mvn_file net.jpountz.lz4:lz4 lz4
%mvn_artifact dist/lz4-java-%{version}.pom dist/lz4-java-%{version}.jar
%mvn_install -J build/docs
@@ -105,6 +106,11 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Tue Dec 01 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-9
+- run unit tests on classes that do not require randomizedtesting
+- add liblz4-java.so generation step to Makefile
+- remove mvn_file macro for lz4
+
* Thu Nov 19 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-8
- remove dependency on cpptasks
commit d057d32f5de7aef5c8bfd5b748abe3e176a4041d
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Wed Nov 18 14:12:23 2020 -0500
remove dependency on cpptasks
diff --git a/3-remove-cpptasks.patch b/3-remove-cpptasks.patch
new file mode 100644
index 0000000..c03318b
--- /dev/null
+++ b/3-remove-cpptasks.patch
@@ -0,0 +1,89 @@
+diff --git a/Makefile b/Makefile
+new file mode 100644
+index 0000000..d762404
+--- /dev/null
++++ b/Makefile
+@@ -0,0 +1,26 @@
++CC = gcc
++
++BUILD_DIR = build
++OBJECTS_DIR = $(BUILD_DIR)/objects
++JNI_HEADERS_DIR = $(BUILD_DIR)/jni-headers
++JNI_SOURCES_DIR = src/jni
++INCLUDE = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux
++
++LIBS = -llz4 -lxxhash
++JNI_PREFIX = net_jpountz_
++
++default: all move_objects
++
++all:
++ $(CC) -I $(JNI_HEADERS_DIR) \
++ $(INCLUDE) \
++ $(LIBS) \
++ -c $(JNI_SOURCES_DIR)/$(JNI_PREFIX)lz4_LZ4JNI.c
++
++ $(CC) -I $(JNI_HEADERS_DIR) \
++ $(INCLUDE) \
++ $(LIBS) \
++ -c $(JNI_SOURCES_DIR)/$(JNI_PREFIX)xxhash_XXHashJNI.c
++
++move_objects:
++ mv *.o $(OBJECTS_DIR)
+\ No newline at end of file
+diff --git a/build.xml b/build.xml
+index 7a63933..dc1a112 100644
+--- a/build.xml
++++ b/build.xml
+@@ -15,7 +15,6 @@
+ -->
+
+ <project name="lz4" default="dist" basedir="."
+- xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
+ xmlns:ivy="antlib:org.apache.ivy.ant"
+ xmlns:junit4="antlib:com.carrotsearch.junit4"
+ xmlns:mvn="antlib:org.apache.maven.artifact.ant">
+@@ -80,13 +79,6 @@
+ <get
src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.ver...
dest="${user.home}/.ant/lib/${ivy.jar.name}"/>
+ </target>
+
+- <target name="install-cpptasks"
unless="cpptasks.available">
+- <ivy:cachepath organisation="ant-contrib" module="cpptasks"
revision="1.0b5"
+- inline="true" conf="default" transitive="true"
pathid="cpptasks.classpath"/>
+- <taskdef uri="antlib:net.sf.antcontrib.cpptasks"
resource="net/sf/antcontrib/cpptasks/antlib.xml"
classpathref="cpptasks.classpath"/>
+- <property name="cpptasks.available" value="true"/>
+- </target>
+-
+ <target name="install-maven-ant-tasks"
unless="maven-ant-tasks.available">
+ <ivy:cachepath organisation="org.apache.maven"
module="maven-ant-tasks" revision="2.1.3"
+ inline="true" conf="default" transitive="true"
pathid="maven-ant-tasks.classpath"/>
+@@ -197,27 +189,10 @@
+ </javah>
+ </target>
+
+- <target name="compile-jni"
depends="install-cpptasks,generate-headers" unless="${skip.jni}">
++ <target name="compile-jni" depends="generate-headers"
unless="${skip.jni}">
+ <mkdir dir="${build}/objects" />
+ <mkdir dir="${build}/jni/net/jpountz/util/${platform}/${os.arch}"
/>
+- <cpptasks:cc
+- debug="false"
+- optimize="extreme"
+- objdir="${build}/objects"
+- outfile="${build}/jni/net/jpountz/util/${platform}/${os.arch}/lz4-java"
+- outtype="shared">
+- <includepath path="${src}/lz4/lib" />
+- <includepath path="${java.home}/../include" />
+- <includepath path="${java.home}/../include/${platform}/" />
+- <!-- In Java 9, java.home points not to jre/ but to the top directory -->
+- <includepath path="${java.home}/include" />
+- <includepath path="${java.home}/include/${platform}/" />
+- <includepath path="${build}/jni-headers" />
+- <fileset dir="${src}/lz4/lib" includes="lz4.c, lz4hc.c,
xxhash.c" />
+- <fileset dir="${src}/jni" includes="*.c" />
+- <linker />
+- <compilerarg value="-mmacosx-version-min=10.9"
if="isMacOS"/>
+- </cpptasks:cc>
++ <exec executable="make" failonerror="true"/>
+ </target>
+
+ <target name="compile" depends="compile-java, compile-jni"
/>
diff --git a/3-use-system-libs.patch b/3-use-system-libs.patch
deleted file mode 100644
index 1ade925..0000000
--- a/3-use-system-libs.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/build.xml b/build.xml
-index 7a63933..7c04e0c 100644
---- a/build.xml
-+++ b/build.xml
-@@ -206,14 +206,13 @@
- objdir="${build}/objects"
- outfile="${build}/jni/net/jpountz/util/${platform}/${os.arch}/lz4-java"
- outtype="shared">
-- <includepath path="${src}/lz4/lib" />
- <includepath path="${java.home}/../include" />
- <includepath path="${java.home}/../include/${platform}/" />
- <!-- In Java 9, java.home points not to jre/ but to the top directory -->
- <includepath path="${java.home}/include" />
- <includepath path="${java.home}/include/${platform}/" />
- <includepath path="${build}/jni-headers" />
-- <fileset dir="${src}/lz4/lib" includes="lz4.c, lz4hc.c,
xxhash.c" />
-+ <libset dir="/usr/lib64" libs="lz4, xxhash" />
- <fileset dir="${src}/jni" includes="*.c" />
- <linker />
- <compilerarg value="-mmacosx-version-min=10.9"
if="isMacOS"/>
diff --git a/lz4-java.spec b/lz4-java.spec
index 51cc04b..0a94e93 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -3,9 +3,9 @@
Name: lz4-java
Version: 1.7.1
-Release: 7%{?dist}
+Release: 8%{?dist}
Summary: LZ4 compression for Java
-License: ASL 2.0 and (BSD and GPLv2+)
+License: ASL 2.0
URL:
https://github.com/lz4/lz4-java
Source0:
https://github.com/lz4/lz4-java/archive/%{version}.tar.gz
@@ -23,14 +23,14 @@ Patch1: 1-remove-unsafe.patch
# This patch simply removes comments from the templates so the classes can be generated
as expected.
# Related bug:
https://github.com/mvel/mvel/issues/152
Patch2: 2-remove-comments-from-templates.patch
-Patch3: 3-use-system-libs.patch
+# Adds a simple makefile to be run in-place of the cpptasks in the build.xml
+Patch3: 3-remove-cpptasks.patch
# Build tools
BuildRequires: apache-parent
BuildRequires: ant
BuildRequires: ant-junit
BuildRequires: aqute-bnd
-BuildRequires: cpptasks
BuildRequires: gcc
BuildRequires: ivy-local
BuildRequires: java-devel
@@ -84,6 +84,12 @@ find -name '*.dylib' -print -delete
find -name '*.so' -print -delete
%build
+%if 0%{?fedora} >= 33
+ export JAVA_HOME=/usr/lib/jvm/java-11/
+%else
+ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
+%endif
+
ant -Divy.mode=local -Divy.revision=1.7.1 -Divy.pom.version=1.7.1 jar docs makepom
bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version %{version}
dist/lz4-java.jar
@@ -99,6 +105,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Thu Nov 19 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-8
+- remove dependency on cpptasks
+
* Mon Nov 16 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-7
- cleanup whitespace in the local patch to remove comments from templates
- use system lz4 and xxhash instead of bundling the dependencies
commit 7b65df5ec6a1a59bc1340634a6804d2e9dbc7e88
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Mon Nov 16 15:21:36 2020 -0500
use system lz4 and xxhash libs instead of bundling
diff --git a/1-remove-unsafe.patch b/1-remove-unsafe.patch
index 9d7b2e7..90adaf3 100644
--- a/1-remove-unsafe.patch
+++ b/1-remove-unsafe.patch
@@ -728,68 +728,6 @@ index 9a9b4d1..9ccdf76 100644
}
/**
-diff --git a/src/lz4/contrib/debian/control b/src/lz4/contrib/debian/control
-index ac3b460..63b493c 100644
---- a/src/lz4/contrib/debian/control
-+++ b/src/lz4/contrib/debian/control
-@@ -13,11 +13,11 @@ Vcs-Browser:
https://github.com/lz4/lz4
-
- Package: liblz4
- Architecture: any
--Depends: ${shlibs:Depends}, ${misc:Depends}
-+Depends: ${shlibs:Depends}
- Description: Extremely Fast Compression algorithm
http://www.lz4.org
-
- Package: liblz4-dev
- Architecture: any
--Depends: ${shlibs:Depends}, ${misc:Depends}
-+Depends: ${shlibs:Depends}
- Description: Extremely Fast Compression algorithm
http://www.lz4.org
- Development files.
-diff --git a/src/lz4/doc/lz4_manual.html b/src/lz4/doc/lz4_manual.html
-index a477584..8127877 100644
---- a/src/lz4/doc/lz4_manual.html
-+++ b/src/lz4/doc/lz4_manual.html
-@@ -316,10 +316,6 @@ int LZ4_freeStreamDecode (LZ4_streamDecode_t*
LZ4_stream);
- future. They are therefore only safe to depend on when the caller is
- statically linked against the library.
-
-- To protect against unsafe usage, not only are the declarations guarded,
-- the definitions are hidden by default
-- when building LZ4 as a shared/dynamic library.
--
- In order to access these declarations,
- define LZ4_STATIC_LINKING_ONLY in your application
- before including LZ4's headers.
-diff --git a/src/lz4/ossfuzz/Makefile b/src/lz4/ossfuzz/Makefile
-index 6875eb6..640d1c7 100644
---- a/src/lz4/ossfuzz/Makefile
-+++ b/src/lz4/ossfuzz/Makefile
-@@ -33,8 +33,7 @@ DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL)
-
- LZ4_CFLAGS = $(CFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
- LZ4_CXXFLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
--LZ4_CPPFLAGS = $(CPPFLAGS) -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ \
-- -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-+LZ4_CPPFLAGS = $(CPPFLAGS) -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
-
- FUZZERS := \
- compress_fuzzer \
-diff --git a/src/lz4/ossfuzz/fuzz.h b/src/lz4/ossfuzz/fuzz.h
-index eefac63..b0e9797 100644
---- a/src/lz4/ossfuzz/fuzz.h
-+++ b/src/lz4/ossfuzz/fuzz.h
-@@ -19,10 +19,6 @@
- * It can be undefined, or 0 through 2. If it is undefined, it selects
- * the method to use based on the compiler. If testing with UBSAN set
- * MEM_FORCE_MEMORY_ACCESS=0 to use the standard compliant method.
-- * @param FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-- * This is the canonical flag to enable deterministic builds for fuzzing.
-- * Changes to zstd for fuzzing are gated behind this define.
-- * It is recommended to define this when building zstd for fuzzing.
- */
-
- #ifndef FUZZ_H
diff --git a/src/test/net/jpountz/lz4/Instances.java
b/src/test/net/jpountz/lz4/Instances.java
index b9caae5..44f7809 100644
--- a/src/test/net/jpountz/lz4/Instances.java
diff --git a/2-remove-comments-from-templates.patch
b/2-remove-comments-from-templates.patch
index 30ec01c..83fb640 100644
--- a/2-remove-comments-from-templates.patch
+++ b/2-remove-comments-from-templates.patch
@@ -1,94 +1,82 @@
diff --git a/src/build/source_templates/compress.template
b/src/build/source_templates/compress.template
-index 0dc3c79..ed47f44 100644
+index 32008e9..09a5df4 100644
--- a/src/build/source_templates/compress.template
+++ b/src/build/source_templates/compress.template
-@@ -16,7 +16,7 @@
+@@ -31,7 +31,6 @@
main:
while (true) {
- // find a match
-+
int forwardOff = sOff;
int ref;
-@@ -36,15 +36,15 @@
+@@ -51,15 +50,12 @@
${type}Utils.writeShort(hashTable, h, sOff - srcOff);
} while (!LZ4${utils}.readIntEquals(src, ref, sOff));
- // catch up
-+
final int excess = LZ4${utils}.commonBytesBackward(src, ref, sOff, srcOff,
anchor);
sOff -= excess;
ref -= excess;
- // sequence == refsequence
-+
final int runLen = sOff - anchor;
- // encode literal length
-+
int tokenOff = dOff++;
if (dOff + runLen + (2 + 1 + LAST_LITERALS) + (runLen >>> 8) >
destEnd) {
-@@ -58,16 +58,16 @@
+@@ -73,16 +69,13 @@
${utils}.writeByte(dest, tokenOff, runLen << ML_BITS);
}
- // copy literals
-+
LZ4${utils}.wildArraycopy(src, anchor, dest, dOff, runLen);
dOff += runLen;
while (true) {
- // encode offset
-+
${utils}.writeShortLE(dest, dOff, (short) (sOff - ref));
dOff += 2;
- // count nb matches
-+
sOff += MIN_MATCH;
ref += MIN_MATCH;
final int matchLen = LZ4${utils}.commonBytes(src, ref, sOff, srcLimit);
-@@ -76,7 +76,7 @@
+@@ -91,7 +84,6 @@
}
sOff += matchLen;
- // encode match len
-+
if (matchLen >= ML_MASK) {
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
ML_MASK);
dOff = LZ4${utils}.writeLen(matchLen - ML_MASK, dest, dOff);
-@@ -84,16 +84,16 @@
+@@ -99,16 +91,13 @@
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
matchLen);
}
- // test end of chunk
-+
if (sOff > mflimit) {
anchor = sOff;
break main;
}
- // fill table
-+
${type}Utils.writeShort(hashTable, hash64k(${utils}.readInt(src, sOff - 2)),
sOff - 2 - srcOff);
- // test next position
-+
final int h = hash64k(${utils}.readInt(src, sOff));
ref = srcOff + ${type}Utils.readShort(hashTable, h);
${type}Utils.writeShort(hashTable, h, sOff - srcOff);
-@@ -106,7 +106,7 @@
+@@ -121,7 +110,6 @@
${utils}.writeByte(dest, tokenOff, 0);
}
- // prepare next loop
-+
anchor = sOff++;
}
}
-@@ -145,7 +145,6 @@
+@@ -160,7 +148,6 @@
main:
while (true) {
@@ -96,7 +84,7 @@ index 0dc3c79..ed47f44 100644
int forwardOff = sOff;
int ref;
-@@ -172,10 +171,8 @@
+@@ -187,10 +174,8 @@
sOff -= excess;
ref -= excess;
@@ -107,83 +95,73 @@ index 0dc3c79..ed47f44 100644
int tokenOff = dOff++;
if (dOff + runLen + (2 + 1 + LAST_LITERALS) + (runLen >>> 8) >
destEnd) {
-@@ -189,16 +186,16 @@
+@@ -204,16 +189,13 @@
${utils}.writeByte(dest, tokenOff, runLen << ML_BITS);
}
- // copy literals
-+
LZ4${utils}.wildArraycopy(src, anchor, dest, dOff, runLen);
dOff += runLen;
while (true) {
- // encode offset
-+
${utils}.writeShortLE(dest, dOff, back);
dOff += 2;
- // count nb matches
-+
sOff += MIN_MATCH;
final int matchLen = LZ4${utils}.commonBytes(src, ref + MIN_MATCH, sOff,
srcLimit);
if (dOff + (1 + LAST_LITERALS) + (matchLen >>> 8) > destEnd) {
-@@ -206,7 +203,7 @@
+@@ -221,7 +203,6 @@
}
sOff += matchLen;
- // encode match len
-+
if (matchLen >= ML_MASK) {
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
ML_MASK);
dOff = LZ4${utils}.writeLen(matchLen - ML_MASK, dest, dOff);
-@@ -214,16 +211,16 @@
+@@ -229,16 +210,13 @@
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
matchLen);
}
- // test end of chunk
-+
if (sOff > mflimit) {
anchor = sOff;
break main;
}
- // fill table
-+
${type}Utils.writeInt(hashTable, hash(${utils}.readInt(src, sOff - 2)), sOff -
2);
- // test next position
-+
final int h = hash(${utils}.readInt(src, sOff));
ref = ${type}Utils.readInt(hashTable, h);
${type}Utils.writeInt(hashTable, h, sOff);
-@@ -237,7 +234,7 @@
+@@ -252,7 +230,6 @@
${utils}.writeByte(dest, tokenOff, 0);
}
- // prepare next loop
-+
anchor = sOff++;
}
diff --git a/src/build/source_templates/compress_hc.template
b/src/build/source_templates/compress_hc.template
-index b09b705..b250205 100644
+index 7179db3..7976ad1 100644
--- a/src/build/source_templates/compress_hc.template
+++ b/src/build/source_templates/compress_hc.template
-@@ -32,7 +32,7 @@
+@@ -47,7 +47,6 @@
continue;
}
- // saved, in case we would skip too much
-+
copyTo(match1, match0);
search2:
-@@ -40,20 +40,20 @@
+@@ -55,20 +54,19 @@
assert match1.start >= anchor;
if (match1.end() >= mfLimit
|| !ht.insertAndFindWiderMatch(src, match1.end() - 2, match1.start + 1,
matchLimit, match1.len, match2)) {
- // no better match
-+
dOff = LZ4${utils}.encodeSequence(src, anchor, match1.start, match1.ref,
match1.len, dest, dOff, destEnd);
anchor = sOff = match1.end();
continue main;
@@ -191,32 +169,29 @@ index b09b705..b250205 100644
if (match0.start < match1.start) {
- if (match2.start < match1.start + match0.len) { // empirical
-+ if (match2.start < match1.start + match0.len) {
++ if (match2.start < match1.start + match0.len) {
copyTo(match0, match1);
}
}
assert match2.start > match1.start;
- if (match2.start - match1.start < 3) { // First Match too small : removed
-+ if (match2.start - match1.start < 3) {
++ if (match2.start - match1.start < 3) {
copyTo(match2, match1);
continue search2;
}
-@@ -76,21 +76,21 @@
+@@ -91,21 +89,18 @@
if (match2.start + match2.len >= mfLimit
|| !ht.insertAndFindWiderMatch(src, match2.end() - 3, match2.start,
matchLimit, match2.len, match3)) {
- // no better match -> 2 sequences to encode
-+
if (match2.start < match1.end()) {
match1.len = match2.start - match1.start;
}
- // encode seq 1
-+
dOff = LZ4${utils}.encodeSequence(src, anchor, match1.start, match1.ref,
match1.len, dest, dOff, destEnd);
anchor = sOff = match1.end();
- // encode seq 2
-+
dOff = LZ4${utils}.encodeSequence(src, anchor, match2.start, match2.ref,
match2.len, dest, dOff, destEnd);
anchor = sOff = match2.end();
continue main;
@@ -224,25 +199,24 @@ index b09b705..b250205 100644
- if (match3.start < match1.end() + 3) { // Not enough space for match 2 :
remove it
- if (match3.start >= match1.end()) { // // can write Seq1 immediately
==> Seq2 is removed, so Seq3 becomes Seq1
-+ if (match3.start < match1.end() + 3) {
-+ if (match3.start >= match1.end()) {
++ if (match3.start < match1.end() + 3) {
++ if (match3.start >= match1.end()) {
if (match2.start < match1.end()) {
final int correction = match1.end() - match2.start;
match2.fix(correction);
-@@ -112,7 +112,7 @@
+@@ -127,7 +122,6 @@
continue search3;
}
- // OK, now we have 3 ascending matches; let's write at least the first
one
-+
if (match2.start < match1.end()) {
if (match2.start - match1.start < ML_MASK) {
if (match1.len > OPTIMAL_ML) {
diff --git a/src/build/source_templates/decompress.template
b/src/build/source_templates/decompress.template
-index 09c0ca8..fce5ace 100644
+index f1c2890..1e2aa23 100644
--- a/src/build/source_templates/decompress.template
+++ b/src/build/source_templates/decompress.template
-@@ -40,7 +40,6 @@
+@@ -55,7 +55,6 @@
final int token = ${utils}.readByte(src, sOff) & 0xFF;
++sOff;
@@ -250,7 +224,7 @@ index 09c0ca8..fce5ace 100644
int literalLen = token >>> ML_BITS;
if (literalLen == RUN_MASK) {
byte len = (byte) 0xFF;
-@@ -66,7 +65,7 @@
+@@ -81,7 +80,7 @@
LZ4${utils}.safeArraycopy(src, sOff, dest, dOff, literalLen);
sOff += literalLen;
dOff = literalCopyEnd;
@@ -259,7 +233,7 @@ index 09c0ca8..fce5ace 100644
}
}
-@@ -74,7 +73,6 @@
+@@ -89,7 +88,6 @@
sOff += literalLen;
dOff = literalCopyEnd;
@@ -268,10 +242,10 @@ index 09c0ca8..fce5ace 100644
sOff += 2;
int matchOff = dOff - matchDec;
diff --git a/src/build/source_templates/hashtable.template
b/src/build/source_templates/hashtable.template
-index ef4e0ac..f6377d0 100644
+index 174f8e8..91935f5 100644
--- a/src/build/source_templates/hashtable.template
+++ b/src/build/source_templates/hashtable.template
-@@ -77,8 +77,8 @@
+@@ -92,8 +92,8 @@
int ref = hashPointer(buf, off);
@@ -282,7 +256,7 @@ index ef4e0ac..f6377d0 100644
delta = off - ref;
repl = match.len = MIN_MATCH + LZ4${utils}.commonBytes(buf, ref + MIN_MATCH,
off + MIN_MATCH, matchLimit);
match.ref = ref;
-@@ -104,7 +104,7 @@
+@@ -119,7 +119,7 @@
int ptr = off;
final int end = off + repl - (MIN_MATCH - 1);
while (ptr < end - delta) {
@@ -291,3 +265,47 @@ index ef4e0ac..f6377d0 100644
++ptr;
}
do {
+diff --git a/src/build/source_templates/xxhash32_streaming.template
b/src/build/source_templates/xxhash32_streaming.template
+index 6166758..9fa55e8 100644
+--- a/src/build/source_templates/xxhash32_streaming.template
++++ b/src/build/source_templates/xxhash32_streaming.template
+@@ -66,7 +66,7 @@ final class StreamingXXHash32Java${type} extends
AbstractStreamingXXHash32Java {
+
+ totalLen += len;
+
+- if (memSize + len < 16) { // fill in tmp buffer
++ if (memSize + len < 16) {
+ System.arraycopy(buf, off, memory, memSize, len);
+ memSize += len;
+ return;
+@@ -74,7 +74,7 @@ final class StreamingXXHash32Java${type} extends
AbstractStreamingXXHash32Java {
+
+ final int end = off + len;
+
+- if (memSize > 0) { // data left from previous update
++ if (memSize > 0) {
+ System.arraycopy(buf, off, memory, memSize, 16 - memSize);
+
+ v1 += readIntLE(memory, 0) * PRIME2;
+diff --git a/src/build/source_templates/xxhash64_streaming.template
b/src/build/source_templates/xxhash64_streaming.template
+index 2789ae0..e781746 100644
+--- a/src/build/source_templates/xxhash64_streaming.template
++++ b/src/build/source_templates/xxhash64_streaming.template
+@@ -90,7 +90,7 @@ final class StreamingXXHash64Java${type} extends
AbstractStreamingXXHash64Java {
+
+ totalLen += len;
+
+- if (memSize + len < 32) { // fill in tmp buffer
++ if (memSize + len < 32) {
+ System.arraycopy(buf, off, memory, memSize, len);
+ memSize += len;
+ return;
+@@ -98,7 +98,7 @@ final class StreamingXXHash64Java${type} extends
AbstractStreamingXXHash64Java {
+
+ final int end = off + len;
+
+- if (memSize > 0) { // data left from previous update
++ if (memSize > 0) {
+ System.arraycopy(buf, off, memory, memSize, 32 - memSize);
+
+ v1 += readLongLE(memory, 0) * PRIME64_2;
diff --git a/3-use-system-libs.patch b/3-use-system-libs.patch
new file mode 100644
index 0000000..1ade925
--- /dev/null
+++ b/3-use-system-libs.patch
@@ -0,0 +1,20 @@
+diff --git a/build.xml b/build.xml
+index 7a63933..7c04e0c 100644
+--- a/build.xml
++++ b/build.xml
+@@ -206,14 +206,13 @@
+ objdir="${build}/objects"
+ outfile="${build}/jni/net/jpountz/util/${platform}/${os.arch}/lz4-java"
+ outtype="shared">
+- <includepath path="${src}/lz4/lib" />
+ <includepath path="${java.home}/../include" />
+ <includepath path="${java.home}/../include/${platform}/" />
+ <!-- In Java 9, java.home points not to jre/ but to the top directory -->
+ <includepath path="${java.home}/include" />
+ <includepath path="${java.home}/include/${platform}/" />
+ <includepath path="${build}/jni-headers" />
+- <fileset dir="${src}/lz4/lib" includes="lz4.c, lz4hc.c,
xxhash.c" />
++ <libset dir="/usr/lib64" libs="lz4, xxhash" />
+ <fileset dir="${src}/jni" includes="*.c" />
+ <linker />
+ <compilerarg value="-mmacosx-version-min=10.9"
if="isMacOS"/>
diff --git a/lz4-java.spec b/lz4-java.spec
index df49bfb..51cc04b 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -1,20 +1,16 @@
# empty debuginfo
%global debug_package %nil
-%global lz4_version 1.9.2
Name: lz4-java
Version: 1.7.1
-Release: 6%{?dist}
+Release: 7%{?dist}
Summary: LZ4 compression for Java
-# GPL:
-# src/lz4/
-# BSD:
-# src/lz4/libs
License: ASL 2.0 and (BSD and GPLv2+)
URL:
https://github.com/lz4/lz4-java
Source0:
https://github.com/lz4/lz4-java/archive/%{version}.tar.gz
-Source1:
https://github.com/lz4/lz4/archive/v%{lz4_version}.tar.gz
+# lz4-java tests require randomizedtesting, which is not currently
+# shipped or maintained in Fedora.
Patch0: 0-remove-tests.patch
# lz4-java v1.3.0 introduced usage of sun.misc.Unsafe, which would later become
# depricated in jdk 9 and kept as an unexposed API in later jdk releases.
@@ -27,8 +23,10 @@ Patch1: 1-remove-unsafe.patch
# This patch simply removes comments from the templates so the classes can be generated
as expected.
# Related bug:
https://github.com/mvel/mvel/issues/152
Patch2: 2-remove-comments-from-templates.patch
+Patch3: 3-use-system-libs.patch
# Build tools
+BuildRequires: apache-parent
BuildRequires: ant
BuildRequires: ant-junit
BuildRequires: aqute-bnd
@@ -37,13 +35,11 @@ BuildRequires: gcc
BuildRequires: ivy-local
BuildRequires: java-devel
BuildRequires: javapackages-local
+BuildRequires: lz4-devel
BuildRequires: mvel
BuildRequires: objectweb-asm
BuildRequires: xerces-j2
-BuildRequires: apache-parent
-# FPC ticket Bundled Library Exception
-#
https://fedorahosted.org/fpc/ticket/603
-Provides: bundled(libxxhash) = r37
+BuildRequires: xxhash-devel
BuildArch: noarch
@@ -77,21 +73,16 @@ This package contains javadoc for %{name}.
%prep
%setup -q -n %{name}-%{version}
-%setup -q -T -D -a 1
-
-mv lz4-1.9.2/* src/lz4/
%patch0 -p1
%patch1 -p1
%patch2 -p1
+%patch3 -p1
# Cleanup
find -name '*.dylib' -print -delete
find -name '*.so' -print -delete
-cp -p src/lz4/LICENSE lz4_LICENSE
-cp -p src/lz4/lib/LICENSE lz4_lib_LICENSE
-
%build
ant -Divy.mode=local -Divy.revision=1.7.1 -Divy.pom.version=1.7.1 jar docs makepom
bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version %{version}
dist/lz4-java.jar
@@ -103,12 +94,15 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%files -f .mfiles
%doc CHANGES.md README.md
-%license LICENSE.txt lz4_LICENSE lz4_lib_LICENSE
%files javadoc -f .mfiles-javadoc
%license LICENSE.txt
%changelog
+* Mon Nov 16 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-7
+- cleanup whitespace in the local patch to remove comments from templates
+- use system lz4 and xxhash instead of bundling the dependencies
+
* Tue Oct 06 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-6
- include patch to strip comments from mvel templates
diff --git a/sources b/sources
index a2c0121..971053e 100644
--- a/sources
+++ b/sources
@@ -1,2 +1 @@
SHA512 (1.7.1.tar.gz) =
13fd89a9564f1f504348ce30a51ca22d5581a6661658d55c96f3f0c1e43126de04d2df87683251a8ec5bf53726f529b60bb1ec666863b7e33810df8ed73bb586
-SHA512 (v1.9.2.tar.gz) =
ae714c61ec8e33ed91359b63f2896cfa102d66b730dce112b74696ec5850e59d88bd5527173e01e354a70fbe8f036557a47c767ee0766bc5f9c257978116c3c1
commit 5dd438e91ef4f1b87dedd92753934b62a719cc53
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Tue Oct 6 17:31:43 2020 -0400
include patch to remove comments from mvel templates
diff --git a/2-remove-comments-from-templates.patch
b/2-remove-comments-from-templates.patch
new file mode 100644
index 0000000..30ec01c
--- /dev/null
+++ b/2-remove-comments-from-templates.patch
@@ -0,0 +1,293 @@
+diff --git a/src/build/source_templates/compress.template
b/src/build/source_templates/compress.template
+index 0dc3c79..ed47f44 100644
+--- a/src/build/source_templates/compress.template
++++ b/src/build/source_templates/compress.template
+@@ -16,7 +16,7 @@
+ main:
+ while (true) {
+
+- // find a match
++
+ int forwardOff = sOff;
+
+ int ref;
+@@ -36,15 +36,15 @@
+ ${type}Utils.writeShort(hashTable, h, sOff - srcOff);
+ } while (!LZ4${utils}.readIntEquals(src, ref, sOff));
+
+- // catch up
++
+ final int excess = LZ4${utils}.commonBytesBackward(src, ref, sOff, srcOff,
anchor);
+ sOff -= excess;
+ ref -= excess;
+
+- // sequence == refsequence
++
+ final int runLen = sOff - anchor;
+
+- // encode literal length
++
+ int tokenOff = dOff++;
+
+ if (dOff + runLen + (2 + 1 + LAST_LITERALS) + (runLen >>> 8) >
destEnd) {
+@@ -58,16 +58,16 @@
+ ${utils}.writeByte(dest, tokenOff, runLen << ML_BITS);
+ }
+
+- // copy literals
++
+ LZ4${utils}.wildArraycopy(src, anchor, dest, dOff, runLen);
+ dOff += runLen;
+
+ while (true) {
+- // encode offset
++
+ ${utils}.writeShortLE(dest, dOff, (short) (sOff - ref));
+ dOff += 2;
+
+- // count nb matches
++
+ sOff += MIN_MATCH;
+ ref += MIN_MATCH;
+ final int matchLen = LZ4${utils}.commonBytes(src, ref, sOff, srcLimit);
+@@ -76,7 +76,7 @@
+ }
+ sOff += matchLen;
+
+- // encode match len
++
+ if (matchLen >= ML_MASK) {
+ ${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
ML_MASK);
+ dOff = LZ4${utils}.writeLen(matchLen - ML_MASK, dest, dOff);
+@@ -84,16 +84,16 @@
+ ${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
matchLen);
+ }
+
+- // test end of chunk
++
+ if (sOff > mflimit) {
+ anchor = sOff;
+ break main;
+ }
+
+- // fill table
++
+ ${type}Utils.writeShort(hashTable, hash64k(${utils}.readInt(src, sOff - 2)),
sOff - 2 - srcOff);
+
+- // test next position
++
+ final int h = hash64k(${utils}.readInt(src, sOff));
+ ref = srcOff + ${type}Utils.readShort(hashTable, h);
+ ${type}Utils.writeShort(hashTable, h, sOff - srcOff);
+@@ -106,7 +106,7 @@
+ ${utils}.writeByte(dest, tokenOff, 0);
+ }
+
+- // prepare next loop
++
+ anchor = sOff++;
+ }
+ }
+@@ -145,7 +145,6 @@
+ main:
+ while (true) {
+
+- // find a match
+ int forwardOff = sOff;
+
+ int ref;
+@@ -172,10 +171,8 @@
+ sOff -= excess;
+ ref -= excess;
+
+- // sequence == refsequence
+ final int runLen = sOff - anchor;
+
+- // encode literal length
+ int tokenOff = dOff++;
+
+ if (dOff + runLen + (2 + 1 + LAST_LITERALS) + (runLen >>> 8) >
destEnd) {
+@@ -189,16 +186,16 @@
+ ${utils}.writeByte(dest, tokenOff, runLen << ML_BITS);
+ }
+
+- // copy literals
++
+ LZ4${utils}.wildArraycopy(src, anchor, dest, dOff, runLen);
+ dOff += runLen;
+
+ while (true) {
+- // encode offset
++
+ ${utils}.writeShortLE(dest, dOff, back);
+ dOff += 2;
+
+- // count nb matches
++
+ sOff += MIN_MATCH;
+ final int matchLen = LZ4${utils}.commonBytes(src, ref + MIN_MATCH, sOff,
srcLimit);
+ if (dOff + (1 + LAST_LITERALS) + (matchLen >>> 8) > destEnd) {
+@@ -206,7 +203,7 @@
+ }
+ sOff += matchLen;
+
+- // encode match len
++
+ if (matchLen >= ML_MASK) {
+ ${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
ML_MASK);
+ dOff = LZ4${utils}.writeLen(matchLen - ML_MASK, dest, dOff);
+@@ -214,16 +211,16 @@
+ ${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) |
matchLen);
+ }
+
+- // test end of chunk
++
+ if (sOff > mflimit) {
+ anchor = sOff;
+ break main;
+ }
+
+- // fill table
++
+ ${type}Utils.writeInt(hashTable, hash(${utils}.readInt(src, sOff - 2)), sOff -
2);
+
+- // test next position
++
+ final int h = hash(${utils}.readInt(src, sOff));
+ ref = ${type}Utils.readInt(hashTable, h);
+ ${type}Utils.writeInt(hashTable, h, sOff);
+@@ -237,7 +234,7 @@
+ ${utils}.writeByte(dest, tokenOff, 0);
+ }
+
+- // prepare next loop
++
+ anchor = sOff++;
+ }
+
+diff --git a/src/build/source_templates/compress_hc.template
b/src/build/source_templates/compress_hc.template
+index b09b705..b250205 100644
+--- a/src/build/source_templates/compress_hc.template
++++ b/src/build/source_templates/compress_hc.template
+@@ -32,7 +32,7 @@
+ continue;
+ }
+
+- // saved, in case we would skip too much
++
+ copyTo(match1, match0);
+
+ search2:
+@@ -40,20 +40,20 @@
+ assert match1.start >= anchor;
+ if (match1.end() >= mfLimit
+ || !ht.insertAndFindWiderMatch(src, match1.end() - 2, match1.start + 1,
matchLimit, match1.len, match2)) {
+- // no better match
++
+ dOff = LZ4${utils}.encodeSequence(src, anchor, match1.start, match1.ref,
match1.len, dest, dOff, destEnd);
+ anchor = sOff = match1.end();
+ continue main;
+ }
+
+ if (match0.start < match1.start) {
+- if (match2.start < match1.start + match0.len) { // empirical
++ if (match2.start < match1.start + match0.len) {
+ copyTo(match0, match1);
+ }
+ }
+ assert match2.start > match1.start;
+
+- if (match2.start - match1.start < 3) { // First Match too small : removed
++ if (match2.start - match1.start < 3) {
+ copyTo(match2, match1);
+ continue search2;
+ }
+@@ -76,21 +76,21 @@
+
+ if (match2.start + match2.len >= mfLimit
+ || !ht.insertAndFindWiderMatch(src, match2.end() - 3, match2.start,
matchLimit, match2.len, match3)) {
+- // no better match -> 2 sequences to encode
++
+ if (match2.start < match1.end()) {
+ match1.len = match2.start - match1.start;
+ }
+- // encode seq 1
++
+ dOff = LZ4${utils}.encodeSequence(src, anchor, match1.start, match1.ref,
match1.len, dest, dOff, destEnd);
+ anchor = sOff = match1.end();
+- // encode seq 2
++
+ dOff = LZ4${utils}.encodeSequence(src, anchor, match2.start, match2.ref,
match2.len, dest, dOff, destEnd);
+ anchor = sOff = match2.end();
+ continue main;
+ }
+
+- if (match3.start < match1.end() + 3) { // Not enough space for match 2 :
remove it
+- if (match3.start >= match1.end()) { // // can write Seq1 immediately
==> Seq2 is removed, so Seq3 becomes Seq1
++ if (match3.start < match1.end() + 3) {
++ if (match3.start >= match1.end()) {
+ if (match2.start < match1.end()) {
+ final int correction = match1.end() - match2.start;
+ match2.fix(correction);
+@@ -112,7 +112,7 @@
+ continue search3;
+ }
+
+- // OK, now we have 3 ascending matches; let's write at least the first
one
++
+ if (match2.start < match1.end()) {
+ if (match2.start - match1.start < ML_MASK) {
+ if (match1.len > OPTIMAL_ML) {
+diff --git a/src/build/source_templates/decompress.template
b/src/build/source_templates/decompress.template
+index 09c0ca8..fce5ace 100644
+--- a/src/build/source_templates/decompress.template
++++ b/src/build/source_templates/decompress.template
+@@ -40,7 +40,6 @@
+ final int token = ${utils}.readByte(src, sOff) & 0xFF;
+ ++sOff;
+
+- // literals
+ int literalLen = token >>> ML_BITS;
+ if (literalLen == RUN_MASK) {
+ byte len = (byte) 0xFF;
+@@ -66,7 +65,7 @@
+ LZ4${utils}.safeArraycopy(src, sOff, dest, dOff, literalLen);
+ sOff += literalLen;
+ dOff = literalCopyEnd;
+- break; // EOF
++ break;
+ }
+ }
+
+@@ -74,7 +73,6 @@
+ sOff += literalLen;
+ dOff = literalCopyEnd;
+
+- // matchs
+ final int matchDec = ${utils}.readShortLE(src, sOff);
+ sOff += 2;
+ int matchOff = dOff - matchDec;
+diff --git a/src/build/source_templates/hashtable.template
b/src/build/source_templates/hashtable.template
+index ef4e0ac..f6377d0 100644
+--- a/src/build/source_templates/hashtable.template
++++ b/src/build/source_templates/hashtable.template
+@@ -77,8 +77,8 @@
+
+ int ref = hashPointer(buf, off);
+
+- if (ref >= off - 4 && ref <= off && ref >= base) { //
potential repetition
+- if (LZ4${utils}.readIntEquals(buf, ref, off)) { // confirmed
++ if (ref >= off - 4 && ref <= off && ref >= base) {
++ if (LZ4${utils}.readIntEquals(buf, ref, off)) {
+ delta = off - ref;
+ repl = match.len = MIN_MATCH + LZ4${utils}.commonBytes(buf, ref + MIN_MATCH,
off + MIN_MATCH, matchLimit);
+ match.ref = ref;
+@@ -104,7 +104,7 @@
+ int ptr = off;
+ final int end = off + repl - (MIN_MATCH - 1);
+ while (ptr < end - delta) {
+- chainTable[ptr & MASK] = (short) delta; // pre load
++ chainTable[ptr & MASK] = (short) delta;
+ ++ptr;
+ }
+ do {
diff --git a/lz4-java.spec b/lz4-java.spec
index be5f837..df49bfb 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -4,7 +4,7 @@
Name: lz4-java
Version: 1.7.1
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: LZ4 compression for Java
# GPL:
# src/lz4/
@@ -20,7 +20,13 @@ Patch0: 0-remove-tests.patch
# depricated in jdk 9 and kept as an unexposed API in later jdk releases.
# lz4-java optionally uses Unsafe to achieve faster compression and decompression,
# however it's implementation is not critical to functionality, and can be removed.
-Patch1: 1-remove-unsafe.patch
+Patch1: 1-remove-unsafe.patch
+# After updating mvel to version 2.4.10, MVEL generated classes have formatting issues
where
+# code after comments are not being formatted with new lines. As a result, including
comments
+# in the templates results in classes with invalid code following the first comment.
+# This patch simply removes comments from the templates so the classes can be generated
as expected.
+# Related bug:
https://github.com/mvel/mvel/issues/152
+Patch2: 2-remove-comments-from-templates.patch
# Build tools
BuildRequires: ant
@@ -77,7 +83,7 @@ mv lz4-1.9.2/* src/lz4/
%patch0 -p1
%patch1 -p1
-
+%patch2 -p1
# Cleanup
find -name '*.dylib' -print -delete
@@ -103,6 +109,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Tue Oct 06 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-6
+- include patch to strip comments from mvel templates
+
* Tue Sep 15 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-5
- add "BuildArch: noarch" to fix rpmlint error: no-binary
commit 27dc0f7171d85d6fb6affd9a3c67d4ba7db5ad39
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Tue Sep 15 13:19:50 2020 -0400
fix rpmlint error no-binary
diff --git a/lz4-java.spec b/lz4-java.spec
index 76c2562..be5f837 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -4,7 +4,7 @@
Name: lz4-java
Version: 1.7.1
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: LZ4 compression for Java
# GPL:
# src/lz4/
@@ -39,6 +39,8 @@ BuildRequires: apache-parent
#
https://fedorahosted.org/fpc/ticket/603
Provides: bundled(libxxhash) = r37
+BuildArch: noarch
+
%description
LZ4 compression for Java, based on Yann Collet's work.
This library provides access to two compression methods
@@ -69,7 +71,7 @@ This package contains javadoc for %{name}.
%prep
%setup -q -n %{name}-%{version}
-%setup -T -D -a 1
+%setup -q -T -D -a 1
mv lz4-1.9.2/* src/lz4/
@@ -101,6 +103,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Tue Sep 15 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-5
+- add "BuildArch: noarch" to fix rpmlint error: no-binary
+
* Wed Sep 09 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-4
- fixed sources to have both lz4-java and lz4
commit 6e88dc63de6df8e81213ddf10fe571c8af4d243f
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Wed Sep 9 16:39:29 2020 -0400
fixed sources to have both lz4-java and lz4
diff --git a/lz4-java.spec b/lz4-java.spec
index e9a1541..76c2562 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -4,7 +4,7 @@
Name: lz4-java
Version: 1.7.1
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: LZ4 compression for Java
# GPL:
# src/lz4/
@@ -101,6 +101,9 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%license LICENSE.txt
%changelog
+* Wed Sep 09 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-4
+- fixed sources to have both lz4-java and lz4
+
* Wed Aug 05 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-3
- used commit from Jie Kang's fork of lz4-java to update to upstream 1.7.1
- this prevents tests from running; eliminates the need for randomizedtesting for f33
onward
diff --git a/sources b/sources
index 971053e..a2c0121 100644
--- a/sources
+++ b/sources
@@ -1 +1,2 @@
SHA512 (1.7.1.tar.gz) =
13fd89a9564f1f504348ce30a51ca22d5581a6661658d55c96f3f0c1e43126de04d2df87683251a8ec5bf53726f529b60bb1ec666863b7e33810df8ed73bb586
+SHA512 (v1.9.2.tar.gz) =
ae714c61ec8e33ed91359b63f2896cfa102d66b730dce112b74696ec5850e59d88bd5527173e01e354a70fbe8f036557a47c767ee0766bc5f9c257978116c3c1
commit 55e0c41000d08f59674c268fe2621703b342184f
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Thu Aug 27 11:17:54 2020 -0400
remove usage of sun.misc.Unsafe
diff --git a/remove-tests.patch b/0-remove-tests.patch
similarity index 100%
rename from remove-tests.patch
rename to 0-remove-tests.patch
diff --git a/1-remove-unsafe.patch b/1-remove-unsafe.patch
new file mode 100644
index 0000000..9d7b2e7
--- /dev/null
+++ b/1-remove-unsafe.patch
@@ -0,0 +1,949 @@
+diff --git a/.classpath b/.classpath
+index 5ee3f97..058b340 100644
+--- a/.classpath
++++ b/.classpath
+@@ -2,7 +2,6 @@
+ <classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="build/java"/>
+- <classpathentry kind="src" path="src/java-unsafe"/>
+ <classpathentry kind="src" path="src/test-resources"/>
+ <classpathentry kind="src" path="build/jni"/>
+ <classpathentry kind="src" path="src/test"/>
+diff --git a/CHANGES.md b/CHANGES.md
+index c7eed89..b71dc35 100644
+--- a/CHANGES.md
++++ b/CHANGES.md
+@@ -140,12 +140,6 @@
+ - [#99](https://github.com/lz4/lz4-java/pull/99)
+ LZ4FrameInputStream allows EndMark to be incompressible. (Charles Allen)
+
+- - [#95](https://github.com/lz4/lz4-java/pull/95)
+- Added unsafe instance support for aarch64. (Yuqi Gu)
+-
+- - [#93](https://github.com/lz4/lz4-java/pull/93)
+- Added unsafe instance support for ppc64le. (Madhusudanan Kandasamy)
+-
+ - [#90](https://github.com/lz4/lz4-java/issues/90)
+ LZ4 Java now supports 64-bit JNI build on Solaris. (cndcourt)
+
+@@ -207,11 +201,6 @@
+ - [#39](https://github.com/jpountz/lz4-java/pull/39)
+ The JAR is now a valid OSGI bundle. (Simon Chemouil)
+
+- - [#33](https://github.com/jpountz/lz4-java/pull/33)
+- The implementation based on Java's sun.misc.Unsafe relies on unaligned
+- memory access and is now only used on platforms that support it.
+- (Dmitry Shohov)
+-
+
+ ## 1.2.0
+
+diff --git a/README.md b/README.md
+index 9a34ea6..b966d9a 100644
+--- a/README.md
++++ b/README.md
+@@ -24,12 +24,10 @@ decompressor instance.
+
+ ## Implementations
+
+-For LZ4 compressors, LZ4 HC compressors and decompressors, 3 implementations are
++For LZ4 compressors, LZ4 HC compressors and decompressors, 2 implementations are
+ available:
+ - JNI bindings to the original C implementation by Yann Collet,
+ - a pure Java port of the compression and decompression algorithms,
+- - a Java port that uses the sun.misc.Unsafe API in order to achieve compression
+- and decompression speeds close to the C implementation.
+
+ Have a look at LZ4Factory for more information.
+
+@@ -94,8 +92,7 @@ score of 10) hash function.
+
+ ## Implementations
+
+-Similarly to LZ4, 3 implementations are available: JNI bindings, pure Java port
+-and pure Java port that uses sun.misc.Unsafe.
++Unsimilarly to LZ4, 2 implementations are available: JNI bindings, pure Java port
+
+ Have a look at XXHashFactory for more information.
+
+@@ -131,7 +128,7 @@ int hash = hash32.getValue();
+
+ You can download released artifacts from [Maven
Central](https://search.maven.org/search?q=g:org.lz4%20a:lz4-java).
+
+-You can download pure-Java lz4-java from [Maven
Central](https://search.maven.org/search?q=g:org.lz4%20a:lz4-pure-java). These artifacts
include the Safe and Unsafe Java versions but not JNI bindings. (Experimental)
++You can download pure-Java lz4-java from [Maven
Central](https://search.maven.org/search?q=g:org.lz4%20a:lz4-pure-java). These artifacts
include the Safe Java versions but not JNI bindings. (Experimental)
+
+ # Documentation
+
+@@ -172,10 +169,8 @@ Then run `ant`. It will:
+ located under `src/build`,
+ - compile the lz4 and xxhash libraries and their JNI (Java Native Interface)
+ bindings,
+- - compile Java sources in `src/java` (normal sources), `src/java-unsafe`
+- (sources that make use of `sun.misc.Unsafe`) and `build/java`
+- (auto-generated sources) to `build/classes`, `build/unsafe-classes` and
+- `build/generated-classes`,
++ - compile Java sources in `src/java` (normal sources) and `build/java`
++ (auto-generated sources) to `build/classes` and `build/generated-classes`,
+ - generate a JAR file called lz4-${version}.jar under the `dist` directory.
+
+ The JAR file that is generated contains Java class files, the native library
+diff --git a/build.xml b/build.xml
+index 2a08ad8..1d4cff5 100644
+--- a/build.xml
++++ b/build.xml
+@@ -148,16 +148,6 @@
+ debug="true"
+ destdir="${build}/classes"
+ nativeHeaderDir="${build}/jni-headers"/>
+- <mkdir dir="${build}/unsafe-classes" />
+- <javac
+- includeAntRuntime="false"
+- srcdir="${src}/java-unsafe"
+- source="${javac.source}"
+- target="${javac.target}"
+- encoding="UTF-8"
+- debug="true"
+- classpath="${build}/classes"
+- destdir="${build}/unsafe-classes"/>
+ <mkdir dir="${build}/generated-classes" />
+ <javac
+ includeAntRuntime="false"
+@@ -169,7 +159,6 @@
+ destdir="${build}/generated-classes">
+ <classpath>
+ <pathelement location="${build}/classes/" />
+- <pathelement location="${build}/unsafe-classes" />
+ </classpath>
+ </javac>
+ </target>
+@@ -234,7 +223,6 @@
+
+ <path id="compile.tests.classpath">
+ <pathelement path="${build}/classes" />
+- <pathelement path="${build}/unsafe-classes" />
+ <pathelement path="${build}/generated-classes" />
+ <fileset dir="lib" includes="*.jar" />
+ </path>
+@@ -249,7 +237,6 @@
+ <pathelement path="${src}/resources" />
+ <pathelement path="${src}/test-resources" />
+ <pathelement path="${build}/classes" />
+- <pathelement path="${build}/unsafe-classes" />
+ <pathelement path="${build}/generated-classes" />
+ <pathelement path="${build}/test-classes" />
+ <fileset dir="${lib}" includes="*.jar" />
+@@ -317,7 +304,6 @@
+ <jar
+ destfile="${dist}/${ivy.module}-${ivy.revision}-sources.jar">
+ <fileset dir="${src}/java" />
+- <fileset dir="${src}/java-unsafe" />
+ </jar>
+ </target>
+
+@@ -351,7 +337,6 @@
+ destfile="${dist}/${ivy.module}.jar">
+ <fileset dir="${src}/resources" erroronmissingdir="false"
/>
+ <fileset dir="${build}/classes" />
+- <fileset dir="${build}/unsafe-classes" />
+ <fileset dir="${build}/generated-classes" />
+ <fileset dir="${build}/jni" erroronmissingdir="false"
/>
+ <manifest>
+@@ -365,7 +350,6 @@
+ <jar
+ destfile="${dist}/${ivy.module}.jar">
+ <fileset dir="${build}/classes" />
+- <fileset dir="${build}/unsafe-classes" />
+ <fileset dir="${build}/generated-classes" />
+ <manifest>
+ <attribute name="Automatic-Module-Name"
value="org.lz4.pure.java"/>
+@@ -411,15 +395,12 @@
+
+ <target name="forbidden-apis" description="check API usage"
depends="install-forbidden-apis,compile">
+ <forbidden-apis internalRuntimeForbidden="true"
classpathref="forbidden-apis.classpath">
+- <bundledSignatures name="jdk-unsafe-${javac.target}"/>
+ <bundledSignatures name="jdk-deprecated-${javac.target}"/>
+ <fileset dir="${build}/classes" includes="**/*.class"
/>
+ </forbidden-apis>
+ <forbidden-apis classpathref="forbidden-apis.classpath">
+- <bundledSignatures name="jdk-unsafe-${javac.target}"/>
+ <bundledSignatures name="jdk-deprecated-${javac.target}"/>
+ <fileset dir="${build}/classes" includes="**/*.class"
/>
+- <fileset dir="${build}/unsafe-classes"
includes="**/*.class" />
+ </forbidden-apis>
+ </target>
+
+diff --git a/src/build/gen_sources.mvel b/src/build/gen_sources.mvel
+index 0f32671..43ebb78 100644
+--- a/src/build/gen_sources.mvel
++++ b/src/build/gen_sources.mvel
+@@ -24,7 +24,7 @@ def dest_file(path) {
+
+ def generate_decompressors() {
+ compiledTemplate = get_template("decompressor.template");
+- for (type : ["Safe", "Unsafe"]) {
++ for (type : ["Safe"]) {
+ for (size : ["Fast", "Safe"]) {
+ dest = dest_file("lz4/LZ4Java" + type + size +
"Decompressor.java");
+ args = new HashMap();
+@@ -37,7 +37,7 @@ def generate_decompressors() {
+
+ def generate_compressors() {
+ compiledTemplate = get_template("compressor.template");
+- for (type : ["Safe", "Unsafe"]) {
++ for (type : ["Safe"]) {
+ dest = dest_file("lz4/LZ4Java" + type + "Compressor.java");
+ args = new HashMap();
+ args.put("type", type);
+@@ -47,7 +47,7 @@ def generate_compressors() {
+
+ def generate_hc_compressors() {
+ compiledTemplate = get_template("compressor_hc.template");
+- for (type : ["Safe", "Unsafe"]) {
++ for (type : ["Safe"]) {
+ dest = dest_file("lz4/LZ4HCJava" + type + "Compressor.java");
+ args = new HashMap();
+ args.put("type", type);
+@@ -58,7 +58,7 @@ def generate_hc_compressors() {
+ def generate_xxhash() {
+ for (bitness : ["32", "64"]) {
+ compiledTemplate = get_template("xxhash" + bitness +
".template");
+- for (type : ["Safe", "Unsafe"]) {
++ for (type : ["Safe"]) {
+ dest = dest_file("xxhash/XXHash" + bitness + "Java" + type +
".java");
+ args = new HashMap();
+ args.put("type", type);
+@@ -70,7 +70,7 @@ def generate_xxhash() {
+ def generate_streaming_xxhash() {
+ for (bitness : ["32", "64"]) {
+ compiledTemplate = get_template("xxhash" + bitness +
"_streaming.template");
+- for (type : ["Safe", "Unsafe"]) {
++ for (type : ["Safe"]) {
+ dest = dest_file("xxhash/StreamingXXHash" + bitness + "Java" +
type + ".java");
+ args = new HashMap();
+ args.put("type", type);
+diff --git a/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java
b/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java
+deleted file mode 100644
+index a5ad783..0000000
+--- a/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java
++++ /dev/null
+@@ -1,206 +0,0 @@
+-package net.jpountz.lz4;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import static net.jpountz.lz4.LZ4Constants.COPY_LENGTH;
+-import static net.jpountz.lz4.LZ4Constants.LAST_LITERALS;
+-import static net.jpountz.lz4.LZ4Constants.ML_BITS;
+-import static net.jpountz.lz4.LZ4Constants.ML_MASK;
+-import static net.jpountz.lz4.LZ4Constants.RUN_MASK;
+-import static net.jpountz.util.UnsafeUtils.readByte;
+-import static net.jpountz.util.UnsafeUtils.readInt;
+-import static net.jpountz.util.UnsafeUtils.readLong;
+-import static net.jpountz.util.UnsafeUtils.readShort;
+-import static net.jpountz.util.UnsafeUtils.writeByte;
+-import static net.jpountz.util.UnsafeUtils.writeInt;
+-import static net.jpountz.util.UnsafeUtils.writeLong;
+-import static net.jpountz.util.UnsafeUtils.writeShort;
+-import static net.jpountz.util.Utils.NATIVE_BYTE_ORDER;
+-
+-import java.nio.ByteOrder;
+-
+-enum LZ4UnsafeUtils {
+- ;
+-
+- static void safeArraycopy(byte[] src, int srcOff, byte[] dest, int destOff, int len)
{
+- final int fastLen = len & 0xFFFFFFF8;
+- wildArraycopy(src, srcOff, dest, destOff, fastLen);
+- for (int i = 0, slowLen = len & 0x7; i < slowLen; i += 1) {
+- writeByte(dest, destOff + fastLen + i, readByte(src, srcOff + fastLen + i));
+- }
+- }
+-
+- static void wildArraycopy(byte[] src, int srcOff, byte[] dest, int destOff, int len)
{
+- for (int i = 0; i < len; i += 8) {
+- writeLong(dest, destOff + i, readLong(src, srcOff + i));
+- }
+- }
+-
+- static void wildIncrementalCopy(byte[] dest, int matchOff, int dOff, int matchCopyEnd)
{
+- if (dOff - matchOff < 4) {
+- for (int i = 0; i < 4; ++i) {
+- writeByte(dest, dOff+i, readByte(dest, matchOff+i));
+- }
+- dOff += 4;
+- matchOff += 4;
+- int dec = 0;
+- assert dOff >= matchOff && dOff - matchOff < 8;
+- switch (dOff - matchOff) {
+- case 1:
+- matchOff -= 3;
+- break;
+- case 2:
+- matchOff -= 2;
+- break;
+- case 3:
+- matchOff -= 3;
+- dec = -1;
+- break;
+- case 5:
+- dec = 1;
+- break;
+- case 6:
+- dec = 2;
+- break;
+- case 7:
+- dec = 3;
+- break;
+- default:
+- break;
+- }
+- writeInt(dest, dOff, readInt(dest, matchOff));
+- dOff += 4;
+- matchOff -= dec;
+- } else if (dOff - matchOff < COPY_LENGTH) {
+- writeLong(dest, dOff, readLong(dest, matchOff));
+- dOff += dOff - matchOff;
+- }
+- while (dOff < matchCopyEnd) {
+- writeLong(dest, dOff, readLong(dest, matchOff));
+- dOff += 8;
+- matchOff += 8;
+- }
+- }
+-
+- static void safeIncrementalCopy(byte[] dest, int matchOff, int dOff, int matchLen) {
+- for (int i = 0; i < matchLen; ++i) {
+- dest[dOff + i] = dest[matchOff + i];
+- writeByte(dest, dOff + i, readByte(dest, matchOff + i));
+- }
+- }
+-
+- static int readShortLittleEndian(byte[] src, int srcOff) {
+- short s = readShort(src, srcOff);
+- if (NATIVE_BYTE_ORDER == ByteOrder.BIG_ENDIAN) {
+- s = Short.reverseBytes(s);
+- }
+- return s & 0xFFFF;
+- }
+-
+- static void writeShortLittleEndian(byte[] dest, int destOff, int value) {
+- short s = (short) value;
+- if (NATIVE_BYTE_ORDER == ByteOrder.BIG_ENDIAN) {
+- s = Short.reverseBytes(s);
+- }
+- writeShort(dest, destOff, s);
+- }
+-
+- static boolean readIntEquals(byte[] src, int ref, int sOff) {
+- return readInt(src, ref) == readInt(src, sOff);
+- }
+-
+- static int commonBytes(byte[] src, int ref, int sOff, int srcLimit) {
+- int matchLen = 0;
+- while (sOff <= srcLimit - 8) {
+- if (readLong(src, sOff) == readLong(src, ref)) {
+- matchLen += 8;
+- ref += 8;
+- sOff += 8;
+- } else {
+- final int zeroBits;
+- if (NATIVE_BYTE_ORDER == ByteOrder.BIG_ENDIAN) {
+- zeroBits = Long.numberOfLeadingZeros(readLong(src, sOff) ^ readLong(src,
ref));
+- } else {
+- zeroBits = Long.numberOfTrailingZeros(readLong(src, sOff) ^ readLong(src,
ref));
+- }
+- return matchLen + (zeroBits >>> 3);
+- }
+- }
+- while (sOff < srcLimit && readByte(src, ref++) == readByte(src, sOff++))
{
+- ++matchLen;
+- }
+- return matchLen;
+- }
+-
+- static int writeLen(int len, byte[] dest, int dOff) {
+- while (len >= 0xFF) {
+- writeByte(dest, dOff++, 0xFF);
+- len -= 0xFF;
+- }
+- writeByte(dest, dOff++, len);
+- return dOff;
+- }
+-
+- static int encodeSequence(byte[] src, int anchor, int matchOff, int matchRef, int
matchLen, byte[] dest, int dOff, int destEnd) {
+- final int runLen = matchOff - anchor;
+- final int tokenOff = dOff++;
+- int token;
+-
+- if (runLen >= RUN_MASK) {
+- token = (byte) (RUN_MASK << ML_BITS);
+- dOff = writeLen(runLen - RUN_MASK, dest, dOff);
+- } else {
+- token = runLen << ML_BITS;
+- }
+-
+- // copy literals
+- wildArraycopy(src, anchor, dest, dOff, runLen);
+- dOff += runLen;
+-
+- // encode offset
+- final int matchDec = matchOff - matchRef;
+- dest[dOff++] = (byte) matchDec;
+- dest[dOff++] = (byte) (matchDec >>> 8);
+-
+- // encode match len
+- matchLen -= 4;
+- if (dOff + (1 + LAST_LITERALS) + (matchLen >>> 8) > destEnd) {
+- throw new LZ4Exception("maxDestLen is too small");
+- }
+- if (matchLen >= ML_MASK) {
+- token |= ML_MASK;
+- dOff = writeLen(matchLen - RUN_MASK, dest, dOff);
+- } else {
+- token |= matchLen;
+- }
+-
+- dest[tokenOff] = (byte) token;
+-
+- return dOff;
+- }
+-
+- static int commonBytesBackward(byte[] b, int o1, int o2, int l1, int l2) {
+- int count = 0;
+- while (o1 > l1 && o2 > l2 && readByte(b, --o1) == readByte(b,
--o2)) {
+- ++count;
+- }
+- return count;
+- }
+-
+- static int lastLiterals(byte[] src, int sOff, int srcLen, byte[] dest, int dOff, int
destEnd) {
+- return LZ4SafeUtils.lastLiterals(src, sOff, srcLen, dest, dOff, destEnd);
+- }
+-
+-}
+diff --git a/src/java-unsafe/net/jpountz/util/UnsafeUtils.java
b/src/java-unsafe/net/jpountz/util/UnsafeUtils.java
+deleted file mode 100644
+index 30231ef..0000000
+--- a/src/java-unsafe/net/jpountz/util/UnsafeUtils.java
++++ /dev/null
+@@ -1,147 +0,0 @@
+-package net.jpountz.util;
+-
+-/*
+- * Licensed under the Apache License, Version 2.0 (the "License");
+- * you may not use this file except in compliance with the License.
+- * You may obtain a copy of the License at
+- *
+- *
http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-
+-import static net.jpountz.util.Utils.NATIVE_BYTE_ORDER;
+-
+-import java.lang.reflect.Field;
+-import java.nio.ByteOrder;
+-
+-import sun.misc.Unsafe;
+-
+-public enum UnsafeUtils {
+- ;
+-
+- private static final Unsafe UNSAFE;
+- private static final long BYTE_ARRAY_OFFSET;
+- private static final int BYTE_ARRAY_SCALE;
+- private static final long INT_ARRAY_OFFSET;
+- private static final int INT_ARRAY_SCALE;
+- private static final long SHORT_ARRAY_OFFSET;
+- private static final int SHORT_ARRAY_SCALE;
+-
+- static {
+- try {
+- Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
+- theUnsafe.setAccessible(true);
+- UNSAFE = (Unsafe) theUnsafe.get(null);
+- BYTE_ARRAY_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
+- BYTE_ARRAY_SCALE = UNSAFE.arrayIndexScale(byte[].class);
+- INT_ARRAY_OFFSET = UNSAFE.arrayBaseOffset(int[].class);
+- INT_ARRAY_SCALE = UNSAFE.arrayIndexScale(int[].class);
+- SHORT_ARRAY_OFFSET = UNSAFE.arrayBaseOffset(short[].class);
+- SHORT_ARRAY_SCALE = UNSAFE.arrayIndexScale(short[].class);
+- } catch (IllegalAccessException e) {
+- throw new ExceptionInInitializerError("Cannot access Unsafe");
+- } catch (NoSuchFieldException e) {
+- throw new ExceptionInInitializerError("Cannot access Unsafe");
+- } catch (SecurityException e) {
+- throw new ExceptionInInitializerError("Cannot access Unsafe");
+- }
+- }
+-
+- public static void checkRange(byte[] buf, int off) {
+- SafeUtils.checkRange(buf, off);
+- }
+-
+- public static void checkRange(byte[] buf, int off, int len) {
+- SafeUtils.checkRange(buf, off, len);
+- }
+-
+- public static void checkLength(int len) {
+- SafeUtils.checkLength(len);
+- }
+-
+- public static byte readByte(byte[] src, int srcOff) {
+- return UNSAFE.getByte(src, BYTE_ARRAY_OFFSET + BYTE_ARRAY_SCALE * srcOff);
+- }
+-
+- public static void writeByte(byte[] src, int srcOff, byte value) {
+- UNSAFE.putByte(src, BYTE_ARRAY_OFFSET + BYTE_ARRAY_SCALE * srcOff, (byte) value);
+- }
+-
+- public static void writeByte(byte[] src, int srcOff, int value) {
+- writeByte(src, srcOff, (byte) value);
+- }
+-
+- public static long readLong(byte[] src, int srcOff) {
+- return UNSAFE.getLong(src, BYTE_ARRAY_OFFSET + srcOff);
+- }
+-
+- public static long readLongLE(byte[] src, int srcOff) {
+- long i = readLong(src, srcOff);
+- if (NATIVE_BYTE_ORDER == ByteOrder.BIG_ENDIAN) {
+- i = Long.reverseBytes(i);
+- }
+- return i;
+- }
+-
+- public static void writeLong(byte[] dest, int destOff, long value) {
+- UNSAFE.putLong(dest, BYTE_ARRAY_OFFSET + destOff, value);
+- }
+-
+- public static int readInt(byte[] src, int srcOff) {
+- return UNSAFE.getInt(src, BYTE_ARRAY_OFFSET + srcOff);
+- }
+-
+- public static int readIntLE(byte[] src, int srcOff) {
+- int i = readInt(src, srcOff);
+- if (NATIVE_BYTE_ORDER == ByteOrder.BIG_ENDIAN) {
+- i = Integer.reverseBytes(i);
+- }
+- return i;
+- }
+-
+- public static void writeInt(byte[] dest, int destOff, int value) {
+- UNSAFE.putInt(dest, BYTE_ARRAY_OFFSET + destOff, value);
+- }
+-
+- public static short readShort(byte[] src, int srcOff) {
+- return UNSAFE.getShort(src, BYTE_ARRAY_OFFSET + srcOff);
+- }
+-
+- public static int readShortLE(byte[] src, int srcOff) {
+- short s = readShort(src, srcOff);
+- if (NATIVE_BYTE_ORDER == ByteOrder.BIG_ENDIAN) {
+- s = Short.reverseBytes(s);
+- }
+- return s & 0xFFFF;
+- }
+-
+- public static void writeShort(byte[] dest, int destOff, short value) {
+- UNSAFE.putShort(dest, BYTE_ARRAY_OFFSET + destOff, value);
+- }
+-
+- public static void writeShortLE(byte[] buf, int off, int v) {
+- writeByte(buf, off, (byte) v);
+- writeByte(buf, off + 1, (byte) (v >>> 8));
+- }
+-
+- public static int readInt(int[] src, int srcOff) {
+- return UNSAFE.getInt(src, INT_ARRAY_OFFSET + INT_ARRAY_SCALE * srcOff);
+- }
+-
+- public static void writeInt(int[] dest, int destOff, int value) {
+- UNSAFE.putInt(dest, INT_ARRAY_OFFSET + INT_ARRAY_SCALE * destOff, value);
+- }
+-
+- public static int readShort(short[] src, int srcOff) {
+- return UNSAFE.getShort(src, SHORT_ARRAY_OFFSET + SHORT_ARRAY_SCALE * srcOff) &
0xFFFF;
+- }
+-
+- public static void writeShort(short[] dest, int destOff, int value) {
+- UNSAFE.putShort(dest, SHORT_ARRAY_OFFSET + SHORT_ARRAY_SCALE * destOff, (short)
value);
+- }
+-}
+diff --git a/src/java/net/jpountz/lz4/LZ4Factory.java
b/src/java/net/jpountz/lz4/LZ4Factory.java
+index e04867b..69f81fa 100644
+--- a/src/java/net/jpountz/lz4/LZ4Factory.java
++++ b/src/java/net/jpountz/lz4/LZ4Factory.java
+@@ -32,8 +32,6 @@ import static net.jpountz.lz4.LZ4Constants.MAX_COMPRESSION_LEVEL;
+ * <a
href="https://github.com/lz4/lz4">the original LZ4 C
implementation</a>.
+ * <li>a {@link #safeInstance() safe Java} instance which is a pure Java port
+ * of the original C library,</li>
+- * <li>an {@link #unsafeInstance() unsafe Java} instance which is a Java port
+- * using the unofficial {@link sun.misc.Unsafe} API.
+ * </ul>
+ * <p>
+ * Only the {@link #safeInstance() safe instance} is guaranteed to work on your
+@@ -55,7 +53,6 @@ public final class LZ4Factory {
+ }
+
+ private static LZ4Factory NATIVE_INSTANCE,
+- JAVA_UNSAFE_INSTANCE,
+ JAVA_SAFE_INSTANCE;
+
+ /**
+@@ -107,42 +104,15 @@ public final class LZ4Factory {
+ return JAVA_SAFE_INSTANCE;
+ }
+
+- /**
+- * Returns a {@link LZ4Factory} instance that returns compressors and
+- * decompressors that may use {@link sun.misc.Unsafe} to speed up compression
+- * and decompression.
+- *
+- * @return a {@link LZ4Factory} instance that returns compressors and
+- * decompressors that may use {@link sun.misc.Unsafe} to speed up compression
+- * and decompression.
+- */
+- public static synchronized LZ4Factory unsafeInstance() {
+- if (JAVA_UNSAFE_INSTANCE == null) {
+- JAVA_UNSAFE_INSTANCE = instance("JavaUnsafe");
+- }
+- return JAVA_UNSAFE_INSTANCE;
+- }
+-
+ /**
+ * Returns the fastest available {@link LZ4Factory} instance which does not
+- * rely on JNI bindings. It first tries to load the
+- * {@link #unsafeInstance() unsafe instance}, and then the
+- * {@link #safeInstance() safe Java instance} if the JVM doesn't have a
+- * working {@link sun.misc.Unsafe}.
++ * rely on JNI bindings. It loads {@link #safeInstance() safe Java instance}
+ *
+ * @return the fastest available {@link LZ4Factory} instance which does not
+ * rely on JNI bindings.
+ */
+ public static LZ4Factory fastestJavaInstance() {
+- if (Utils.isUnalignedAccessAllowed()) {
+- try {
+- return unsafeInstance();
+- } catch (Throwable t) {
+- return safeInstance();
+- }
+- } else {
+ return safeInstance();
+- }
+ }
+
+ /**
+@@ -249,9 +219,9 @@ public final class LZ4Factory {
+ * <li>A compression level lower than 1 would be treated as 9.</li>
+ * </ol>
+ * Note that compression levels from different implementations
+- * (native, unsafe Java, and safe Java) cannot be compared with one another.
++ * (native, and safe Java) cannot be compared with one another.
+ * Specifically, the native implementation of a high compression level
+- * is not necessarily faster than the safe/unsafe Java implementation
++ * is not necessarily faster than the safe Java implementation
+ * of the same compression level.
+ *
+ * @param compressionLevel the compression level between [1, 17]; the higher the
level, the higher the compression ratio
+diff --git a/src/java/net/jpountz/xxhash/XXHashFactory.java
b/src/java/net/jpountz/xxhash/XXHashFactory.java
+index 9a9b4d1..9ccdf76 100644
+--- a/src/java/net/jpountz/xxhash/XXHashFactory.java
++++ b/src/java/net/jpountz/xxhash/XXHashFactory.java
+@@ -28,8 +28,6 @@ import net.jpountz.util.Utils;
+ * <a
href="http://code.google.com/p/xxhash/">the original LZ4 C
implementation</a>.
+ * <li>a {@link #safeInstance() safe Java} instance which is a pure Java port
+ * of the original C library,</li>
+- * <li>an {@link #unsafeInstance() unsafe Java} instance which is a Java port
+- * using the unofficial {@link sun.misc.Unsafe} API.
+ * </ul>
+ * <p>
+ * Only the {@link #safeInstance() safe instance} is guaranteed to work on your
+@@ -51,7 +49,6 @@ public final class XXHashFactory {
+ }
+
+ private static XXHashFactory NATIVE_INSTANCE,
+- JAVA_UNSAFE_INSTANCE,
+ JAVA_SAFE_INSTANCE;
+
+ /**
+@@ -96,40 +93,15 @@ public final class XXHashFactory {
+ return JAVA_SAFE_INSTANCE;
+ }
+
+- /**
+- * Returns a {@link XXHashFactory} that returns {@link XXHash32} instances that
+- * may use {@link sun.misc.Unsafe} to speed up hashing.
+- *
+- * @return a {@link XXHashFactory} that returns {@link XXHash32} instances that
+- * may use {@link sun.misc.Unsafe} to speed up hashing.
+- */
+- public static synchronized XXHashFactory unsafeInstance() {
+- if (JAVA_UNSAFE_INSTANCE == null) {
+- JAVA_UNSAFE_INSTANCE = instance("JavaUnsafe");
+- }
+- return JAVA_UNSAFE_INSTANCE;
+- }
+-
+ /**
+ * Returns the fastest available {@link XXHashFactory} instance which does not
+- * rely on JNI bindings. It first tries to load the
+- * {@link #unsafeInstance() unsafe instance}, and then the
+- * {@link #safeInstance() safe Java instance} if the JVM doesn't have a
+- * working {@link sun.misc.Unsafe}.
++ * rely on JNI bindings. It loads {@link #safeInstance() safe instance}
+ *
+ * @return the fastest available {@link XXHashFactory} instance which does not
+ * rely on JNI bindings.
+ */
+ public static XXHashFactory fastestJavaInstance() {
+- if (Utils.isUnalignedAccessAllowed()) {
+- try {
+- return unsafeInstance();
+- } catch (Throwable t) {
+- return safeInstance();
+- }
+- } else {
+ return safeInstance();
+- }
+ }
+
+ /**
+diff --git a/src/lz4/contrib/debian/control b/src/lz4/contrib/debian/control
+index ac3b460..63b493c 100644
+--- a/src/lz4/contrib/debian/control
++++ b/src/lz4/contrib/debian/control
+@@ -13,11 +13,11 @@ Vcs-Browser:
https://github.com/lz4/lz4
+
+ Package: liblz4
+ Architecture: any
+-Depends: ${shlibs:Depends}, ${misc:Depends}
++Depends: ${shlibs:Depends}
+ Description: Extremely Fast Compression algorithm
http://www.lz4.org
+
+ Package: liblz4-dev
+ Architecture: any
+-Depends: ${shlibs:Depends}, ${misc:Depends}
++Depends: ${shlibs:Depends}
+ Description: Extremely Fast Compression algorithm
http://www.lz4.org
+ Development files.
+diff --git a/src/lz4/doc/lz4_manual.html b/src/lz4/doc/lz4_manual.html
+index a477584..8127877 100644
+--- a/src/lz4/doc/lz4_manual.html
++++ b/src/lz4/doc/lz4_manual.html
+@@ -316,10 +316,6 @@ int LZ4_freeStreamDecode (LZ4_streamDecode_t*
LZ4_stream);
+ future. They are therefore only safe to depend on when the caller is
+ statically linked against the library.
+
+- To protect against unsafe usage, not only are the declarations guarded,
+- the definitions are hidden by default
+- when building LZ4 as a shared/dynamic library.
+-
+ In order to access these declarations,
+ define LZ4_STATIC_LINKING_ONLY in your application
+ before including LZ4's headers.
+diff --git a/src/lz4/ossfuzz/Makefile b/src/lz4/ossfuzz/Makefile
+index 6875eb6..640d1c7 100644
+--- a/src/lz4/ossfuzz/Makefile
++++ b/src/lz4/ossfuzz/Makefile
+@@ -33,8 +33,7 @@ DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL)
+
+ LZ4_CFLAGS = $(CFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
+ LZ4_CXXFLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
+-LZ4_CPPFLAGS = $(CPPFLAGS) -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ \
+- -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
++LZ4_CPPFLAGS = $(CPPFLAGS) -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
+
+ FUZZERS := \
+ compress_fuzzer \
+diff --git a/src/lz4/ossfuzz/fuzz.h b/src/lz4/ossfuzz/fuzz.h
+index eefac63..b0e9797 100644
+--- a/src/lz4/ossfuzz/fuzz.h
++++ b/src/lz4/ossfuzz/fuzz.h
+@@ -19,10 +19,6 @@
+ * It can be undefined, or 0 through 2. If it is undefined, it selects
+ * the method to use based on the compiler. If testing with UBSAN set
+ * MEM_FORCE_MEMORY_ACCESS=0 to use the standard compliant method.
+- * @param FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+- * This is the canonical flag to enable deterministic builds for fuzzing.
+- * Changes to zstd for fuzzing are gated behind this define.
+- * It is recommended to define this when building zstd for fuzzing.
+ */
+
+ #ifndef FUZZ_H
+diff --git a/src/test/net/jpountz/lz4/Instances.java
b/src/test/net/jpountz/lz4/Instances.java
+index b9caae5..44f7809 100644
+--- a/src/test/net/jpountz/lz4/Instances.java
++++ b/src/test/net/jpountz/lz4/Instances.java
+@@ -21,21 +21,17 @@ enum Instances {
+ static LZ4Compressor[] COMPRESSORS = new LZ4Compressor[] {
+ LZ4Factory.nativeInstance().fastCompressor(),
+ LZ4Factory.nativeInstance().highCompressor(),
+- LZ4Factory.unsafeInstance().fastCompressor(),
+- LZ4Factory.unsafeInstance().highCompressor(),
+ LZ4Factory.safeInstance().fastCompressor(),
+ LZ4Factory.safeInstance().highCompressor()
+ };
+
+ static LZ4FastDecompressor[] FAST_DECOMPRESSORS = new LZ4FastDecompressor[] {
+ LZ4Factory.nativeInstance().fastDecompressor(),
+- LZ4Factory.unsafeInstance().fastDecompressor(),
+ LZ4Factory.safeInstance().fastDecompressor()
+ };
+
+ static LZ4SafeDecompressor[] SAFE_DECOMPRESSORS = new LZ4SafeDecompressor[] {
+ LZ4Factory.nativeInstance().safeDecompressor(),
+- LZ4Factory.unsafeInstance().safeDecompressor(),
+ LZ4Factory.safeInstance().safeDecompressor()
+ };
+
+diff --git a/src/test/net/jpountz/lz4/LZ4FactoryTest.java
b/src/test/net/jpountz/lz4/LZ4FactoryTest.java
+index c4ef05e..b8b33d7 100644
+--- a/src/test/net/jpountz/lz4/LZ4FactoryTest.java
++++ b/src/test/net/jpountz/lz4/LZ4FactoryTest.java
+@@ -21,17 +21,13 @@ public class LZ4FactoryTest extends TestCase {
+ public void test() {
+ assertEquals(LZ4JNICompressor.INSTANCE,
LZ4Factory.nativeInstance().fastCompressor());
+ assertEquals(LZ4HCJNICompressor.INSTANCE,
LZ4Factory.nativeInstance().highCompressor());
+- assertEquals(LZ4JavaUnsafeCompressor.INSTANCE,
LZ4Factory.unsafeInstance().fastCompressor());
+- assertEquals(LZ4HCJavaUnsafeCompressor.INSTANCE,
LZ4Factory.unsafeInstance().highCompressor());
+ assertEquals(LZ4JavaSafeCompressor.INSTANCE,
LZ4Factory.safeInstance().fastCompressor());
+ assertEquals(LZ4HCJavaSafeCompressor.INSTANCE,
LZ4Factory.safeInstance().highCompressor());
+
+ assertEquals(LZ4JNIFastDecompressor.INSTANCE,
LZ4Factory.nativeInstance().fastDecompressor());
+- assertEquals(LZ4JavaUnsafeFastDecompressor.INSTANCE,
LZ4Factory.unsafeInstance().fastDecompressor());
+ assertEquals(LZ4JavaSafeFastDecompressor.INSTANCE,
LZ4Factory.safeInstance().fastDecompressor());
+
+ assertEquals(LZ4JNISafeDecompressor.INSTANCE,
LZ4Factory.nativeInstance().safeDecompressor());
+- assertEquals(LZ4JavaUnsafeSafeDecompressor.INSTANCE,
LZ4Factory.unsafeInstance().safeDecompressor());
+ assertEquals(LZ4JavaSafeSafeDecompressor.INSTANCE,
LZ4Factory.safeInstance().safeDecompressor());
+ }
+
+diff --git a/src/test/net/jpountz/lz4/LZ4Test.java
b/src/test/net/jpountz/lz4/LZ4Test.java
+index 161899c..6a3a597 100644
+--- a/src/test/net/jpountz/lz4/LZ4Test.java
++++ b/src/test/net/jpountz/lz4/LZ4Test.java
+@@ -247,11 +247,9 @@ public class LZ4Test extends AbstractLZ4Test {
+ public void testRoundTrip(byte[] data, int off, int len) {
+ for (LZ4Factory compressorFactory : Arrays.asList(
+ LZ4Factory.nativeInstance(),
+- LZ4Factory.unsafeInstance(),
+ LZ4Factory.safeInstance())) {
+ for (LZ4Factory decompressorFactory : Arrays.asList(
+ LZ4Factory.nativeInstance(),
+- LZ4Factory.unsafeInstance(),
+ LZ4Factory.safeInstance())) {
+ testRoundTrip(data, off, len, compressorFactory, decompressorFactory);
+ }
+diff --git a/src/test/net/jpountz/xxhash/XXHash32Test.java
b/src/test/net/jpountz/xxhash/XXHash32Test.java
+index 98c9436..30f985d 100644
+--- a/src/test/net/jpountz/xxhash/XXHash32Test.java
++++ b/src/test/net/jpountz/xxhash/XXHash32Test.java
+@@ -74,18 +74,12 @@ public class XXHash32Test extends AbstractLZ4Test {
+
+ private static XXHash32[] INSTANCES = new XXHash32[] {
+ XXHashFactory.nativeInstance().hash32(),
+- XXHashFactory.unsafeInstance().hash32(),
+ XXHashFactory.safeInstance().hash32(),
+ new StreamingXXHash32Adapter() {
+ protected StreamingXXHash32 streamingHash(int seed) {
+ return XXHashFactory.nativeInstance().newStreamingHash32(seed);
+ }
+ },
+- new StreamingXXHash32Adapter() {
+- protected StreamingXXHash32 streamingHash(int seed) {
+- return XXHashFactory.unsafeInstance().newStreamingHash32(seed);
+- }
+- },
+ new StreamingXXHash32Adapter() {
+ protected StreamingXXHash32 streamingHash(int seed) {
+ return XXHashFactory.safeInstance().newStreamingHash32(seed);
+@@ -150,13 +144,10 @@ public class XXHash32Test extends AbstractLZ4Test {
+ long totalLen = 0;
+ final int seed = randomInt();
+ StreamingXXHash32 hash1 = XXHashFactory.nativeInstance().newStreamingHash32(seed);
+- StreamingXXHash32 hash2 = XXHashFactory.unsafeInstance().newStreamingHash32(seed);
+ StreamingXXHash32 hash3 = XXHashFactory.safeInstance().newStreamingHash32(seed);
+ while (totalLen < (1L << 33)) {
+ hash1.update(bytes, off, len);
+- hash2.update(bytes, off, len);
+ hash3.update(bytes, off, len);
+- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
+ assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
+ totalLen += len;
+ }
+diff --git a/src/test/net/jpountz/xxhash/XXHash64Test.java
b/src/test/net/jpountz/xxhash/XXHash64Test.java
+index dadbeda..b767c99 100644
+--- a/src/test/net/jpountz/xxhash/XXHash64Test.java
++++ b/src/test/net/jpountz/xxhash/XXHash64Test.java
+@@ -74,18 +74,12 @@ public class XXHash64Test extends AbstractLZ4Test {
+
+ private static XXHash64[] INSTANCES = new XXHash64[] {
+ XXHashFactory.nativeInstance().hash64(),
+- XXHashFactory.unsafeInstance().hash64(),
+ XXHashFactory.safeInstance().hash64(),
+ new StreamingXXHash64Adapter() {
+ protected StreamingXXHash64 streamingHash(long seed) {
+ return XXHashFactory.nativeInstance().newStreamingHash64(seed);
+ }
+ },
+- new StreamingXXHash64Adapter() {
+- protected StreamingXXHash64 streamingHash(long seed) {
+- return XXHashFactory.unsafeInstance().newStreamingHash64(seed);
+- }
+- },
+ new StreamingXXHash64Adapter() {
+ protected StreamingXXHash64 streamingHash(long seed) {
+ return XXHashFactory.safeInstance().newStreamingHash64(seed);
+@@ -155,13 +149,10 @@ public class XXHash64Test extends AbstractLZ4Test {
+ long totalLen = 0;
+ final long seed = randomLong();
+ StreamingXXHash64 hash1 = XXHashFactory.nativeInstance().newStreamingHash64(seed);
+- StreamingXXHash64 hash2 = XXHashFactory.unsafeInstance().newStreamingHash64(seed);
+ StreamingXXHash64 hash3 = XXHashFactory.safeInstance().newStreamingHash64(seed);
+ while (totalLen < (1L << 33)) {
+ hash1.update(bytes, off, len);
+- hash2.update(bytes, off, len);
+ hash3.update(bytes, off, len);
+- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
+ assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
+ totalLen += len;
+ }
+diff --git a/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
b/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
+index c410220..2aae562 100644
+--- a/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
++++ b/src/test/net/jpountz/xxhash/XXHashFactoryTest.java
+@@ -21,14 +21,10 @@ public class XXHashFactoryTest extends TestCase {
+ public void test() {
+ assertEquals(XXHash32JNI.INSTANCE, XXHashFactory.nativeInstance().hash32());
+ assertTrue(XXHashFactory.nativeInstance().newStreamingHash32(0) instanceof
StreamingXXHash32JNI);
+- assertEquals(XXHash32JavaUnsafe.INSTANCE, XXHashFactory.unsafeInstance().hash32());
+- assertTrue(XXHashFactory.unsafeInstance().newStreamingHash32(0) instanceof
StreamingXXHash32JavaUnsafe);
+ assertEquals(XXHash32JavaSafe.INSTANCE, XXHashFactory.safeInstance().hash32());
+ assertTrue(XXHashFactory.safeInstance().newStreamingHash32(0) instanceof
StreamingXXHash32JavaSafe);
+ assertEquals(XXHash64JNI.INSTANCE, XXHashFactory.nativeInstance().hash64());
+ assertTrue(XXHashFactory.nativeInstance().newStreamingHash64(0) instanceof
StreamingXXHash64JNI);
+- assertEquals(XXHash64JavaUnsafe.INSTANCE, XXHashFactory.unsafeInstance().hash64());
+- assertTrue(XXHashFactory.unsafeInstance().newStreamingHash64(0) instanceof
StreamingXXHash64JavaUnsafe);
+ assertEquals(XXHash64JavaSafe.INSTANCE, XXHashFactory.safeInstance().hash64());
+ assertTrue(XXHashFactory.safeInstance().newStreamingHash64(0) instanceof
StreamingXXHash64JavaSafe);
+ }
diff --git a/lz4-java.spec b/lz4-java.spec
index 58c42c9..e9a1541 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -15,7 +15,12 @@ URL:
https://github.com/lz4/lz4-java
Source0:
https://github.com/lz4/lz4-java/archive/%{version}.tar.gz
Source1:
https://github.com/lz4/lz4/archive/v%{lz4_version}.tar.gz
-Patch0: remove-tests.patch
+Patch0: 0-remove-tests.patch
+# lz4-java v1.3.0 introduced usage of sun.misc.Unsafe, which would later become
+# depricated in jdk 9 and kept as an unexposed API in later jdk releases.
+# lz4-java optionally uses Unsafe to achieve faster compression and decompression,
+# however it's implementation is not critical to functionality, and can be removed.
+Patch1: 1-remove-unsafe.patch
# Build tools
BuildRequires: ant
@@ -28,7 +33,6 @@ BuildRequires: java-devel
BuildRequires: javapackages-local
BuildRequires: mvel
BuildRequires: objectweb-asm
-# BuildRequires: bea-stax-api
BuildRequires: xerces-j2
BuildRequires: apache-parent
# FPC ticket Bundled Library Exception
@@ -67,9 +71,11 @@ This package contains javadoc for %{name}.
%setup -q -n %{name}-%{version}
%setup -T -D -a 1
+mv lz4-1.9.2/* src/lz4/
+
%patch0 -p1
+%patch1 -p1
-mv lz4-1.9.2/* src/lz4/
# Cleanup
find -name '*.dylib' -print -delete
@@ -98,6 +104,8 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
* Wed Aug 05 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-3
- used commit from Jie Kang's fork of lz4-java to update to upstream 1.7.1
- this prevents tests from running; eliminates the need for randomizedtesting for f33
onward
+- remove dependency on bea-stax
+- remove all usage of sun.misc.Unsafe
* Tue Aug 04 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-2
- Included the lz4 submodule inside the lz4-java source tarball
commit 5ddabdc9562bbd33bbbab4b94686f8c190724e97
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Wed Aug 26 16:53:05 2020 -0400
try removing bea-stax-api dep
diff --git a/lz4-java.spec b/lz4-java.spec
index a55ee03..58c42c9 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -28,7 +28,7 @@ BuildRequires: java-devel
BuildRequires: javapackages-local
BuildRequires: mvel
BuildRequires: objectweb-asm
-BuildRequires: bea-stax-api
+# BuildRequires: bea-stax-api
BuildRequires: xerces-j2
BuildRequires: apache-parent
# FPC ticket Bundled Library Exception
commit 0e7a009652555261c0836cfbf3b3e52ff89379e0
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Wed Aug 5 16:38:46 2020 -0400
update to commit from fork/jkang/rpm/lz4-java
diff --git a/.gitignore b/.gitignore
index 5f52bbc..c85324f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/1.3.0.tar.gz
/1.7.1.tar.gz
+/v1.9.2.tar.gz
diff --git a/0-build.patch b/0-build.patch
deleted file mode 100644
index 5624f08..0000000
--- a/0-build.patch
+++ /dev/null
@@ -1,141 +0,0 @@
-diff --git a/build.xml b/build.xml
-index 7a63933..e48d5dd 100644
---- a/build.xml
-+++ b/build.xml
-@@ -17,8 +17,7 @@
- <project name="lz4" default="dist" basedir="."
- xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
- xmlns:ivy="antlib:org.apache.ivy.ant"
-- xmlns:junit4="antlib:com.carrotsearch.junit4"
-- xmlns:mvn="antlib:org.apache.maven.artifact.ant">
-+ xmlns:junit4="antlib:com.carrotsearch.junit4">
-
- <property name="src" location="src"/>
- <property name="build" location="build"/>
-@@ -76,8 +75,6 @@
- </target>
-
- <target name="-ivy-install" unless="ivy.available">
-- <mkdir dir="${user.home}/.ant/lib" />
-- <get
src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.ver...
dest="${user.home}/.ant/lib/${ivy.jar.name}"/>
- </target>
-
- <target name="install-cpptasks"
unless="cpptasks.available">
-@@ -88,10 +85,6 @@
- </target>
-
- <target name="install-maven-ant-tasks"
unless="maven-ant-tasks.available">
-- <ivy:cachepath organisation="org.apache.maven"
module="maven-ant-tasks" revision="2.1.3"
-- inline="true" conf="default" transitive="true"
pathid="maven-ant-tasks.classpath"/>
-- <taskdef uri="antlib:org.apache.maven.artifact.ant"
resource="org/apache/maven/artifact/ant/antlib.xml"
classpathref="maven-ant-tasks.classpath"/>
-- <property name="maven-ant-tasks.available" value="true"/>
- </target>
-
- <target name="install-forbidden-apis"
unless="forbidden-apis.available">
-@@ -102,11 +95,6 @@
- </target>
-
- <target name="install-bnd" unless="bnd.available">
-- <!-- using bnd 1.50.0 because more recent versions have broken JAR wrapping
-->
-- <ivy:cachepath organisation="biz.aQute" module="bnd"
revision="1.50.0"
-- inline="true" conf="default" transitive="true"
pathid="bnd.classpath"/>
-- <taskdef resource="aQute/bnd/ant/taskdef.properties"
classpathref="bnd.classpath"/>
-- <property name="bnd.available" value="true"/>
- </target>
-
- <target name="init">
-@@ -124,9 +112,15 @@
- <property name="junit4.available" value="true" />
- </target>
-
-+ <path id="mvel.classpath">
-+ <fileset dir="/usr/share/java">
-+ <include name="mvel.jar"/>
-+ <include name="objectweb-asm/asm.jar"/>
-+ <include name="objectweb-asm/asm-util.jar"/>
-+ </fileset>
-+ </path>
-+
- <target name="generate-sources" depends="init">
-- <ivy:cachepath organisation="org.mvel" module="mvel2"
revision="2.3.2.Final"
-- inline="true" conf="default" transitive="true"
pathid="mvel.classpath"/>
- <mkdir dir="${build}/java" />
- <java
- fork="true"
-@@ -329,7 +323,9 @@
- overview="${src}/java/overview.html"
- packagenames="net.jpountz.lz4,net.jpountz.xxhash"
- windowtitle="lz4 / xxhash - Java API ${ivy.revision}"
-- destDir="${build}/docs">
-+ destDir="${build}/docs"
-+ encoding="UTF-8"
-+ additionalparam="-Xdoclint:none">
- <link
href="http://download.oracle.com/javase/6/docs/api/" />
- <sourcepath>
- <pathelement location="${src}/java"/>
-@@ -375,8 +371,12 @@
- </jar>
- </target>
-
-- <target name="bundle" description="makes the JAR a valid OSGi
bundle" depends="install-bnd, jar">
-- <taskdef resource="aQute/bnd/ant/taskdef.properties"
classpathref="bnd.classpath"/>
-+ <target name="bundle" description="makes the JAR a valid OSGi
bundle" depends="jar">
-+ <taskdef resource="aQute/bnd/ant/taskdef.properties" >
-+ <classpath>
-+ <fileset dir="/usr/share/java/aqute-bnd"/>
-+ </classpath>
-+ </taskdef>
- <property name="packages.version"
value="${ivy.revision}"/>
- <!-- We need to remove potential -SNAPSHOT qualifiers as package versions...
-->
- <script language="javascript">
-@@ -411,7 +411,7 @@
- <antcall target="dist" />
- </target>
-
-- <target name="forbidden-apis" description="check API usage"
depends="install-forbidden-apis,compile">
-+ <target name="forbidden-apis" description="check API usage"
depends="compile">
- <forbidden-apis internalRuntimeForbidden="true"
classpathref="forbidden-apis.classpath">
- <bundledSignatures name="jdk-unsafe-${javac.target}"/>
- <bundledSignatures name="jdk-deprecated-${javac.target}"/>
-@@ -429,41 +429,22 @@
- <attribute name="repositoryid" />
- <attribute name="repositoryurl" />
- <sequential>
-- <mvn:mvn>
-- <arg
value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"
/>
-- <arg value="-Durl=@{repositoryurl}" />
-- <arg value="-DrepositoryId=@{repositoryid}" />
-- <arg value="-DpomFile=${dist}/${ivy.module}-${ivy.revision}.pom"
/>
-- <arg value="-Dfile=${dist}/${ivy.module}-${ivy.revision}.jar"
/>
-- <arg
value="-Dfiles=${dist}/${ivy.module}-${ivy.revision}-sources.jar,${dist}/${ivy.module}-${ivy.revision}-javadoc.jar"
/>
-- <arg value="-Dclassifiers=sources,javadoc" />
-- <arg value="-Dtypes=jar,jar" />
-- <arg value="-Pgpg" />
-- </mvn:mvn>
- </sequential>
- </macrodef>
-
- <target name="deploy" description="deploy snapshot to snapshot
repo" depends="install-maven-ant-tasks">
-- <property name="skip.jni" value="true" />
-- <antcall target="-deploy" />
- </target>
-
- <target name="-deploy" depends="clean,dist">
-- <deploy repositoryid="sonatype-nexus-snapshots"
repositoryurl="https://oss.sonatype.org/content/repositories/snapsho... />
- </target>
-
- <!-- before this, update project version from SNAPSHOT to RELEASE -->
- <target name="stage" description="deploy to release repo"
depends="install-maven-ant-tasks,test-skip-jni,forbidden-apis">
-- <property name="skip.jni" value="true" />
-- <antcall target="-stage" />
- </target>
-
- <target name="stage-skip-test" description="deploy to release repo,
skipping tests" depends="install-maven-ant-tasks,forbidden-apis">
-- <property name="skip.jni" value="true" />
-- <antcall target="-stage" />
- </target>
-
- <target name="-stage" depends="clean,dist">
-- <deploy repositoryid="sonatype-nexus-staging"
repositoryurl="https://oss.sonatype.org/service/local/staging/deploy...
/>
- </target>
- </project>
diff --git a/1-junit_Assert.patch b/1-junit_Assert.patch
deleted file mode 100644
index 6b0075f..0000000
--- a/1-junit_Assert.patch
+++ /dev/null
@@ -1,316 +0,0 @@
-diff -Nru lz4-java-1.3.0/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
---- lz4-java-1.3.0/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java 2014-11-26
20:04:10.000000000 +0100
-+++
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java 2016-05-03
17:08:40.285741530 +0200
-@@ -207,11 +207,11 @@
-
- final LZ4FastDecompressor decompressor =
LZ4Factory.fastestInstance().fastDecompressor();
- InputStream is = new LZ4BlockInputStream(open(compressed.toByteArray()),
decompressor, checksum);
-- assertFalse(is.markSupported());
-+ org.junit.Assert.assertFalse(is.markSupported());
- try {
- is.mark(1);
- is.reset();
-- assertFalse(true);
-+ org.junit.Assert.assertFalse(true);
- } catch (IOException e) {
- // OK
- }
-@@ -235,8 +235,8 @@
- }
- }
- is.close();
-- assertEquals(data.length, read);
-- assertArrayEquals(data, Arrays.copyOf(restored, read));
-+ org.junit.Assert.assertEquals(data.length, read);
-+ org.junit.Assert.assertArrayEquals(data, Arrays.copyOf(restored, read));
-
- // test skip
- final int offset = data.length <= 1 ? 0 : randomInt(data.length - 1);
-@@ -246,17 +246,17 @@
- read = 0;
- while (read < offset) {
- final long skipped = is.skip(offset - read);
-- assertTrue(skipped >= 0);
-+ org.junit.Assert.assertTrue(skipped >= 0);
- read += skipped;
- }
- read = 0;
- while (read < length) {
- final int r = is.read(restored, read, length - read);
-- assertTrue(r >= 0);
-+ org.junit.Assert.assertTrue(r >= 0);
- read += r;
- }
- is.close();
-- assertArrayEquals(Arrays.copyOfRange(data, offset, offset + length),
Arrays.copyOfRange(restored, 0, length));
-+ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, offset, offset +
length), Arrays.copyOfRange(restored, 0, length));
- }
-
- @Test
-@@ -288,7 +288,7 @@
- byte[] actual = new byte[testBytes.length];
- in.read(actual);
-
-- assertArrayEquals(testBytes, actual);
-+ org.junit.Assert.assertArrayEquals(testBytes, actual);
-
- in.close();
- in.close();
-diff -Nru lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash32Test.java
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash32Test.java
---- lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash32Test.java 2014-11-26
20:04:10.000000000 +0100
-+++ lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash32Test.java 2016-05-03
17:08:40.278738569 +0200
-@@ -129,12 +129,12 @@
- final int ref = XXHashFactory.nativeInstance().hash32().hash(buf, off, len, seed);
- for (XXHash32 hash : INSTANCES) {
- final int h = hash.hash(buf, off, len, seed);
-- assertEquals(hash.toString(), ref, h);
-+ org.junit.Assert.assertEquals(hash.toString(), ref, h);
- final ByteBuffer copy = copyOf(buf, off, len);
- final int h2 = hash.hash(copy, off, len, seed);
-- assertEquals(off, copy.position());
-- assertEquals(len, copy.remaining());
-- assertEquals(hash.toString(), ref, h2);
-+ org.junit.Assert.assertEquals(off, copy.position());
-+ org.junit.Assert.assertEquals(len, copy.remaining());
-+ org.junit.Assert.assertEquals(hash.toString(), ref, h2);
- }
- }
-
-@@ -155,8 +155,8 @@
- hash1.update(bytes, off, len);
- hash2.update(bytes, off, len);
- hash3.update(bytes, off, len);
-- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
-- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
-+ org.junit.Assert.assertEquals(hash2.toString() + " " + totalLen,
hash1.getValue(), hash2.getValue());
-+ org.junit.Assert.assertEquals(hash3.toString() + " " + totalLen,
hash1.getValue(), hash3.getValue());
- totalLen += len;
- }
- }
-diff -Nru lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash64Test.java
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash64Test.java
---- lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash64Test.java 2014-11-26
20:04:10.000000000 +0100
-+++ lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash64Test.java 2016-05-03
17:08:40.278738569 +0200
-@@ -134,12 +134,12 @@
- final long ref = XXHashFactory.nativeInstance().hash64().hash(buf, off, len, seed);
- for (XXHash64 hash : INSTANCES) {
- final long h = hash.hash(buf, off, len, seed);
-- assertEquals(hash.toString(), ref, h);
-+ org.junit.Assert.assertEquals(hash.toString(), ref, h);
- final ByteBuffer copy = copyOf(buf, off, len);
- final long h2 = hash.hash(copy, off, len, seed);
-- assertEquals(off, copy.position());
-- assertEquals(len, copy.remaining());
-- assertEquals(hash.toString(), ref, h2);
-+ org.junit.Assert.assertEquals(off, copy.position());
-+ org.junit.Assert.assertEquals(len, copy.remaining());
-+ org.junit.Assert.assertEquals(hash.toString(), ref, h2);
- }
- }
-
-@@ -160,8 +160,8 @@
- hash1.update(bytes, off, len);
- hash2.update(bytes, off, len);
- hash3.update(bytes, off, len);
-- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
-- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
-+ org.junit.Assert.assertEquals(hash2.toString() + " " + totalLen,
hash1.getValue(), hash2.getValue());
-+ org.junit.Assert.assertEquals(hash3.toString() + " " + totalLen,
hash1.getValue(), hash3.getValue());
- totalLen += len;
- }
- }
-diff --git a/src/test/net/jpountz/lz4/LZ4Test.java
b/src/test/net/jpountz/lz4/LZ4Test.java
-index 739fdaf..6d27121 100644
---- a/src/test/net/jpountz/lz4/LZ4Test.java
-+++ b/src/test/net/jpountz/lz4/LZ4Test.java
-@@ -56,7 +56,7 @@ public class LZ4Test extends AbstractLZ4Test {
- if (tempLibFiles != null) {
- for (File tempLibFile : tempLibFiles) {
- File lckFile = new File(tempLibFile.getAbsolutePath() + ".lck");
-- assertTrue(tempLibFile.getAbsolutePath(), lckFile.exists());
-+ org.junit.Assert.assertTrue(tempLibFile.getAbsolutePath(), lckFile.exists());
- }
- }
- }
-@@ -70,7 +70,7 @@ public class LZ4Test extends AbstractLZ4Test {
- for (File tempLockFile : tempLockFiles) {
- String tempLockFilePath = tempLockFile.getAbsolutePath();
- File libFile = new File(tempLockFilePath.substring(0, tempLockFilePath.length() - 4));
-- assertTrue(tempLockFilePath, libFile.exists());
-+ org.junit.Assert.assertTrue(tempLockFilePath, libFile.exists());
- }
- }
- }
-@@ -80,7 +80,7 @@ public class LZ4Test extends AbstractLZ4Test {
- public void testMaxCompressedLength() {
- final int len = randomBoolean() ? randomInt(16) : randomInt(1 << 30);
- for (LZ4Compressor compressor : COMPRESSORS) {
-- assertEquals(LZ4JNI.LZ4_compressBound(len), compressor.maxCompressedLength(len));
-+ org.junit.Assert.assertEquals(LZ4JNI.LZ4_compressBound(len),
compressor.maxCompressedLength(len));
- }
- }
-
-@@ -116,8 +116,8 @@ public class LZ4Test extends AbstractLZ4Test {
- byte[] compressed = getCompressedWorstCase(decompressed);
- byte[] restored = new byte[decompressed.length];
- int cpLen = decompressor.decompress(compressed, 0, restored, 0,
decompressed.length);
-- assertEquals(compressed.length, cpLen);
-- assertArrayEquals(decompressed, restored);
-+ org.junit.Assert.assertEquals(compressed.length, cpLen);
-+ org.junit.Assert.assertArrayEquals(decompressed, restored);
- }
-
- @Test
-@@ -134,8 +134,8 @@ public class LZ4Test extends AbstractLZ4Test {
- byte[] compressed = getCompressedWorstCase(decompressed);
- byte[] restored = new byte[decompressed.length];
- int uncpLen = decompressor.decompress(compressed, 0, compressed.length, restored,
0);
-- assertEquals(decompressed.length, uncpLen);
-- assertArrayEquals(decompressed, restored);
-+ org.junit.Assert.assertEquals(decompressed.length, uncpLen);
-+ org.junit.Assert.assertArrayEquals(decompressed, restored);
- }
-
- @Test
-@@ -169,8 +169,8 @@ public class LZ4Test extends AbstractLZ4Test {
-
- // test decompression
- final T restored = tester.allocate(len);
-- assertEquals(compressedLen, tester.decompress(decompressor, compressed, 0, restored,
0, len));
-- assertArrayEquals(Arrays.copyOfRange(data, off, off + len), tester.copyOf(restored,
0, len));
-+ org.junit.Assert.assertEquals(compressedLen, tester.decompress(decompressor,
compressed, 0, restored, 0, len));
-+ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
-
- // make sure it fails if the compression dest is not large enough
- tester.fill(restored, randomByte());
-@@ -183,8 +183,8 @@ public class LZ4Test extends AbstractLZ4Test {
- // because the compressor is allowed to return different compression results
- // even when it is invoked with the same input data.
- // In this case, just make sure the compressed data can be successfully
decompressed.
-- assertEquals(compressedLen2, tester.decompress(decompressor, compressed2, 0,
restored, 0, len));
-- assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
-+ org.junit.Assert.assertEquals(compressedLen2, tester.decompress(decompressor,
compressed2, 0, restored, 0, len));
-+ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -194,7 +194,7 @@ public class LZ4Test extends AbstractLZ4Test {
- // decompression dest is too small
- try {
- tester.decompress(decompressor, compressed, 0, restored, 0, len - 1);
-- fail();
-+ org.junit.Assert.fail();
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -204,7 +204,7 @@ public class LZ4Test extends AbstractLZ4Test {
- final T restored2 = tester.allocate(len+1);
- try {
- final int cpLen = tester.decompress(decompressor, compressed, 0, restored2, 0, len +
1);
-- fail("compressedLen=" + cpLen);
-+ org.junit.Assert.fail("compressedLen=" + cpLen);
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -212,17 +212,17 @@ public class LZ4Test extends AbstractLZ4Test {
- // try decompression when only the size of the compressed buffer is known
- if (len > 0) {
- tester.fill(restored, randomByte());
-- assertEquals(len, tester.decompress(decompressor2, compressed, 0, compressedLen,
restored, 0, len));
-- assertArrayEquals(Arrays.copyOfRange(data, off, off + len), tester.copyOf(restored, 0,
len));
-+ org.junit.Assert.assertEquals(len, tester.decompress(decompressor2, compressed, 0,
compressedLen, restored, 0, len));
-+ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
- tester.fill(restored, randomByte());
- } else {
-- assertEquals(0, tester.decompress(decompressor2, compressed, 0, compressedLen,
tester.allocate(1), 0, 1));
-+ org.junit.Assert.assertEquals(0, tester.decompress(decompressor2, compressed, 0,
compressedLen, tester.allocate(1), 0, 1));
- }
-
- // over-estimated compressed length
- try {
- final int decompressedLen = tester.decompress(decompressor2, compressed, 0,
compressedLen + 1, tester.allocate(len + 100), 0, len + 100);
-- fail("decompressedLen=" + decompressedLen);
-+ org.junit.Assert.fail("decompressedLen=" + decompressedLen);
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -231,7 +231,7 @@ public class LZ4Test extends AbstractLZ4Test {
- try {
- final int decompressedLen = tester.decompress(decompressor2, compressed, 0,
compressedLen - 1, tester.allocate(len + 100), 0, len + 100);
- if (!(decompressor2 instanceof LZ4JNISafeDecompressor)) {
-- fail("decompressedLen=" + decompressedLen);
-+ org.junit.Assert.fail("decompressedLen=" + decompressedLen);
- }
- } catch (LZ4Exception e) {
- // OK
-@@ -307,7 +307,7 @@ public class LZ4Test extends AbstractLZ4Test {
- try {
- // it is invalid to end with a match, should be at least 5 literals
- decompressor.decompress(invalid, 0, new byte[decompressedLength], 0,
decompressedLength);
-- assertTrue(decompressor.toString(), false);
-+ org.junit.Assert.assertTrue(decompressor.toString(), false);
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -317,7 +317,7 @@ public class LZ4Test extends AbstractLZ4Test {
- try {
- // it is invalid to end with a match, should be at least 5 literals
- decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
-- assertTrue(false);
-+ org.junit.Assert.assertTrue(false);
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -337,7 +337,7 @@ public class LZ4Test extends AbstractLZ4Test {
- try {
- // it is invalid to end with a match, should be at least 5 literals
- decompressor.decompress(invalid, 0, new byte[20], 0, 20);
-- assertTrue(decompressor.toString(), false);
-+ org.junit.Assert.assertTrue(decompressor.toString(), false);
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -347,7 +347,7 @@ public class LZ4Test extends AbstractLZ4Test {
- try {
- // it is invalid to end with a match, should be at least 5 literals
- decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
-- assertTrue(false);
-+ org.junit.Assert.assertTrue(false);
- } catch (LZ4Exception e) {
- // OK
- }
-@@ -362,7 +362,7 @@ public class LZ4Test extends AbstractLZ4Test {
- ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
- try {
- compressor.compress(in, out);
-- fail();
-+ org.junit.Assert.fail();
- } catch (ReadOnlyBufferException e) {
- // ok
- }
-@@ -372,7 +372,7 @@ public class LZ4Test extends AbstractLZ4Test {
- ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
- try {
- decompressor.decompress(in, out);
-- fail();
-+ org.junit.Assert.fail();
- } catch (ReadOnlyBufferException e) {
- // ok
- }
-@@ -383,7 +383,7 @@ public class LZ4Test extends AbstractLZ4Test {
- out.limit(2);
- try {
- decompressor.decompress(in, out);
-- fail();
-+ org.junit.Assert.fail();
- } catch (ReadOnlyBufferException e) {
- // ok
- }
-@@ -486,7 +486,7 @@ public class LZ4Test extends AbstractLZ4Test {
- }
- final Sequence sequence1 = readSequence(expected, off);
- final Sequence sequence2 = readSequence(actual, off);
-- assertEquals(message + ", off=" + off + ", decompressedOff=" +
decompressedOff, sequence1, sequence2);
-+ org.junit.Assert.assertEquals(message + ", off=" + off + ",
decompressedOff=" + decompressedOff, sequence1, sequence2);
- off += sequence1.length;
- decompressedOff += sequence1.literalLen + sequence1.matchLen;
- }
diff --git a/lz4-java.spec b/lz4-java.spec
index 0c25295..a55ee03 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -1,34 +1,21 @@
# empty debuginfo
%global debug_package %nil
-
-%global build_opts -Doffline=true -Divy.mode=local
-Divysettings.xml=/etc/ivy/ivysettings.xml -Divy.revision=%{version}
+%global lz4_version 1.9.2
Name: lz4-java
Version: 1.7.1
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: LZ4 compression for Java
-# GPL: src/xxhash/bench.c
-# src/lz4/programs
-# BSD: src/xxhash/xxhash.c src/xxhash/xxhash.h
-# src/lz4
-License: ASL 2.0
-URL:
https://github.com/jpountz/lz4-java
-Source0:
https://github.com/jpountz/lz4-java/archive/%{version}.tar.gz
-
-# From version 1.5 onwards, lz4-java uses lz4 as a submodule
-# lz4-java/src/lz4 -> lz4/lz4
-# lz4-java in particular uses lz4 version 1.9.2
-# Version1: v1.9.2
-# License: BSD 2-Clause license (for files in lib) and GPLv2
-# URL:
https://github.com/lz4/lz4
-# Source1:
https://github.com/lz4/lz4/archive/v.1.9.2.tar.gz
-
-# Disable maven-ant-tasks and old aqute-bnd (1.50.x) support
-# Add support for system mvel2
-# Fix doclint/encoding in javadoc task
-Patch0: 0-build.patch
-# Use randomizedtesting <= 2.1.3
-Patch1: 1-junit_Assert.patch
+# GPL:
+# src/lz4/
+# BSD:
+# src/lz4/libs
+License: ASL 2.0 and (BSD and GPLv2+)
+URL:
https://github.com/lz4/lz4-java
+Source0:
https://github.com/lz4/lz4-java/archive/%{version}.tar.gz
+Source1:
https://github.com/lz4/lz4/archive/v%{lz4_version}.tar.gz
+
+Patch0: remove-tests.patch
# Build tools
BuildRequires: ant
@@ -39,18 +26,11 @@ BuildRequires: gcc
BuildRequires: ivy-local
BuildRequires: java-devel
BuildRequires: javapackages-local
-BuildRequires: lz4
BuildRequires: mvel
BuildRequires: objectweb-asm
-BuildRequires: randomizedtesting-junit4-ant
-# Other missing build deps
BuildRequires: bea-stax-api
BuildRequires: xerces-j2
BuildRequires: apache-parent
-#
https://github.com/jpountz/lz4-java/issues/74
-# lz4 >= r128 is incompatible with lz4-java apparently
-# due to differences in the framing implementation
-Provides: bundled(lz4) = r122
# FPC ticket Bundled Library Exception
#
https://fedorahosted.org/fpc/ticket/603
Provides: bundled(libxxhash) = r37
@@ -84,28 +64,22 @@ BuildArch: noarch
This package contains javadoc for %{name}.
%prep
-
%setup -q -n %{name}-%{version}
-# Cleanup
-find -name '*.dylib' -print -delete
-find -name '*.so' -print -delete
-
-# Build lz4
-make -C ./src/lz4/
-# make install -C ./src/lz4/
+%setup -T -D -a 1
%patch0 -p1
-%patch1 -p1
-# Fix OSGi manifest entries
-echo "Export-Package: net.jpountz.*,!linux.*" >> lz4.bnd
-sed -i '/packages.version/d' lz4.bnd
+mv lz4-1.9.2/* src/lz4/
-%build
+# Cleanup
+find -name '*.dylib' -print -delete
+find -name '*.so' -print -delete
-ant %build_opts -Divy.pom.version=%{version} jar docs makepom
+cp -p src/lz4/LICENSE lz4_LICENSE
+cp -p src/lz4/lib/LICENSE lz4_lib_LICENSE
-# bundle task use old bnd wrap configuration, is not usable
+%build
+ant -Divy.mode=local -Divy.revision=1.7.1 -Divy.pom.version=1.7.1 jar docs makepom
bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version %{version}
dist/lz4-java.jar
%install
@@ -113,22 +87,18 @@ bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version
%{version} di
%mvn_artifact dist/lz4-java-%{version}.pom dist/lz4-java-%{version}.jar
%mvn_install -J build/docs
-%ifnarch %{arm} aarch64 ppc64
-# FIXME - tests fail on aarch64 for unknown reason.
-# On armhfp tests are skipped due to poor JVM performance ("Execution
-# time total: 3 hours 37 minutes 14 seconds" ... waste of time)
-%check
-ant %build_opts test
-%endif
-
%files -f .mfiles
%doc CHANGES.md README.md
-%license LICENSE.txt ./src/lz4/LICENSE
+%license LICENSE.txt lz4_LICENSE lz4_lib_LICENSE
%files javadoc -f .mfiles-javadoc
%license LICENSE.txt
%changelog
+* Wed Aug 05 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-3
+- used commit from Jie Kang's fork of lz4-java to update to upstream 1.7.1
+- this prevents tests from running; eliminates the need for randomizedtesting for f33
onward
+
* Tue Aug 04 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-2
- Included the lz4 submodule inside the lz4-java source tarball
diff --git a/remove-tests.patch b/remove-tests.patch
new file mode 100644
index 0000000..a12b749
--- /dev/null
+++ b/remove-tests.patch
@@ -0,0 +1,26 @@
+diff --git a/ivy-pure-java.xml b/ivy-pure-java.xml
+index 6e99e19..58f4c53 100644
+--- a/ivy-pure-java.xml
++++ b/ivy-pure-java.xml
+@@ -19,8 +19,4 @@
+ <conf name="default" />
+ <conf name="test" extends="default" />
+ </configurations>
+-
+- <dependencies>
+- <dependency org="com.carrotsearch.randomizedtesting"
name="junit4-ant" rev="2.7.3" transitive="true"
conf="test->*,!sources,!javadoc" />
+- </dependencies>
+ </ivy-module>
+diff --git a/ivy.xml b/ivy.xml
+index 6643da7..4e3798c 100644
+--- a/ivy.xml
++++ b/ivy.xml
+@@ -19,8 +19,4 @@
+ <conf name="default" />
+ <conf name="test" extends="default" />
+ </configurations>
+-
+- <dependencies>
+- <dependency org="com.carrotsearch.randomizedtesting"
name="junit4-ant" rev="2.7.3" transitive="true"
conf="test->*,!sources,!javadoc" />
+- </dependencies>
+ </ivy-module>
diff --git a/sources b/sources
index 5a74eba..971053e 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (1.7.1.tar.gz) =
c11dab1fbd4a4585fe1f825a61a25f83f2fd5d47e8458c12cd024d6b9b87f8484dbfd60c21b2739e091c177c888b051f31bc8dd46b58041b2d340d3680e2e683
+SHA512 (1.7.1.tar.gz) =
13fd89a9564f1f504348ce30a51ca22d5581a6661658d55c96f3f0c1e43126de04d2df87683251a8ec5bf53726f529b60bb1ec666863b7e33810df8ed73bb586
commit e1e679ba29b6908c358f1e2890e8815c4e1036bb
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Tue Aug 4 12:43:33 2020 -0400
Included the lz4 submodule inside the lz4-java source tarball
diff --git a/lz4-java.spec b/lz4-java.spec
index c0587ed..0c25295 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -5,16 +5,24 @@
Name: lz4-java
Version: 1.7.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: LZ4 compression for Java
# GPL: src/xxhash/bench.c
# src/lz4/programs
# BSD: src/xxhash/xxhash.c src/xxhash/xxhash.h
# src/lz4
-License: ASL 2.0 and (BSD and GPLv2+)
+License: ASL 2.0
URL:
https://github.com/jpountz/lz4-java
Source0:
https://github.com/jpountz/lz4-java/archive/%{version}.tar.gz
+# From version 1.5 onwards, lz4-java uses lz4 as a submodule
+# lz4-java/src/lz4 -> lz4/lz4
+# lz4-java in particular uses lz4 version 1.9.2
+# Version1: v1.9.2
+# License: BSD 2-Clause license (for files in lib) and GPLv2
+# URL:
https://github.com/lz4/lz4
+# Source1:
https://github.com/lz4/lz4/archive/v.1.9.2.tar.gz
+
# Disable maven-ant-tasks and old aqute-bnd (1.50.x) support
# Add support for system mvel2
# Fix doclint/encoding in javadoc task
@@ -31,6 +39,7 @@ BuildRequires: gcc
BuildRequires: ivy-local
BuildRequires: java-devel
BuildRequires: javapackages-local
+BuildRequires: lz4
BuildRequires: mvel
BuildRequires: objectweb-asm
BuildRequires: randomizedtesting-junit4-ant
@@ -75,11 +84,16 @@ BuildArch: noarch
This package contains javadoc for %{name}.
%prep
+
%setup -q -n %{name}-%{version}
# Cleanup
find -name '*.dylib' -print -delete
find -name '*.so' -print -delete
+# Build lz4
+make -C ./src/lz4/
+# make install -C ./src/lz4/
+
%patch0 -p1
%patch1 -p1
@@ -91,12 +105,12 @@ sed -i '/packages.version/d' lz4.bnd
ant %build_opts -Divy.pom.version=%{version} jar docs makepom
-# bunlde task use old bnd wrap configuration, is not usable
-bnd wrap -p lz4.bnd -o dist/lz4-%{version}.jar --version %{version} dist/lz4.jar
+# bundle task use old bnd wrap configuration, is not usable
+bnd wrap -p lz4-java.bnd -o dist/lz4-java-%{version}.jar --version %{version}
dist/lz4-java.jar
%install
%mvn_file net.jpountz.lz4:lz4 lz4
-%mvn_artifact dist/lz4-%{version}.pom dist/lz4-%{version}.jar
+%mvn_artifact dist/lz4-java-%{version}.pom dist/lz4-java-%{version}.jar
%mvn_install -J build/docs
%ifnarch %{arm} aarch64 ppc64
@@ -109,12 +123,15 @@ ant %build_opts test
%files -f .mfiles
%doc CHANGES.md README.md
-%license LICENSE.txt LICENSE.xxhash lz4_LICENSE
+%license LICENSE.txt ./src/lz4/LICENSE
%files javadoc -f .mfiles-javadoc
%license LICENSE.txt
%changelog
+* Tue Aug 04 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-2
+- Included the lz4 submodule inside the lz4-java source tarball
+
* Thu Jul 30 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-1
- Update to version 1.7.1
diff --git a/sources b/sources
index 971053e..5a74eba 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (1.7.1.tar.gz) =
13fd89a9564f1f504348ce30a51ca22d5581a6661658d55c96f3f0c1e43126de04d2df87683251a8ec5bf53726f529b60bb1ec666863b7e33810df8ed73bb586
+SHA512 (1.7.1.tar.gz) =
c11dab1fbd4a4585fe1f825a61a25f83f2fd5d47e8458c12cd024d6b9b87f8484dbfd60c21b2739e091c177c888b051f31bc8dd46b58041b2d340d3680e2e683
commit 1f4f7c08846f011477313f9d5f5b841f6a662fe4
Author: Alex Macdonald <almacdon(a)redhat.com>
Date: Thu Jul 30 11:24:46 2020 -0400
update to version 1.7.1
diff --git a/.gitignore b/.gitignore
index 4700149..5f52bbc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/1.3.0.tar.gz
+/1.7.1.tar.gz
diff --git a/0-build.patch b/0-build.patch
new file mode 100644
index 0000000..5624f08
--- /dev/null
+++ b/0-build.patch
@@ -0,0 +1,141 @@
+diff --git a/build.xml b/build.xml
+index 7a63933..e48d5dd 100644
+--- a/build.xml
++++ b/build.xml
+@@ -17,8 +17,7 @@
+ <project name="lz4" default="dist" basedir="."
+ xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
+ xmlns:ivy="antlib:org.apache.ivy.ant"
+- xmlns:junit4="antlib:com.carrotsearch.junit4"
+- xmlns:mvn="antlib:org.apache.maven.artifact.ant">
++ xmlns:junit4="antlib:com.carrotsearch.junit4">
+
+ <property name="src" location="src"/>
+ <property name="build" location="build"/>
+@@ -76,8 +75,6 @@
+ </target>
+
+ <target name="-ivy-install" unless="ivy.available">
+- <mkdir dir="${user.home}/.ant/lib" />
+- <get
src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.ver...
dest="${user.home}/.ant/lib/${ivy.jar.name}"/>
+ </target>
+
+ <target name="install-cpptasks"
unless="cpptasks.available">
+@@ -88,10 +85,6 @@
+ </target>
+
+ <target name="install-maven-ant-tasks"
unless="maven-ant-tasks.available">
+- <ivy:cachepath organisation="org.apache.maven"
module="maven-ant-tasks" revision="2.1.3"
+- inline="true" conf="default" transitive="true"
pathid="maven-ant-tasks.classpath"/>
+- <taskdef uri="antlib:org.apache.maven.artifact.ant"
resource="org/apache/maven/artifact/ant/antlib.xml"
classpathref="maven-ant-tasks.classpath"/>
+- <property name="maven-ant-tasks.available" value="true"/>
+ </target>
+
+ <target name="install-forbidden-apis"
unless="forbidden-apis.available">
+@@ -102,11 +95,6 @@
+ </target>
+
+ <target name="install-bnd" unless="bnd.available">
+- <!-- using bnd 1.50.0 because more recent versions have broken JAR wrapping
-->
+- <ivy:cachepath organisation="biz.aQute" module="bnd"
revision="1.50.0"
+- inline="true" conf="default" transitive="true"
pathid="bnd.classpath"/>
+- <taskdef resource="aQute/bnd/ant/taskdef.properties"
classpathref="bnd.classpath"/>
+- <property name="bnd.available" value="true"/>
+ </target>
+
+ <target name="init">
+@@ -124,9 +112,15 @@
+ <property name="junit4.available" value="true" />
+ </target>
+
++ <path id="mvel.classpath">
++ <fileset dir="/usr/share/java">
++ <include name="mvel.jar"/>
++ <include name="objectweb-asm/asm.jar"/>
++ <include name="objectweb-asm/asm-util.jar"/>
++ </fileset>
++ </path>
++
+ <target name="generate-sources" depends="init">
+- <ivy:cachepath organisation="org.mvel" module="mvel2"
revision="2.3.2.Final"
+- inline="true" conf="default" transitive="true"
pathid="mvel.classpath"/>
+ <mkdir dir="${build}/java" />
+ <java
+ fork="true"
+@@ -329,7 +323,9 @@
+ overview="${src}/java/overview.html"
+ packagenames="net.jpountz.lz4,net.jpountz.xxhash"
+ windowtitle="lz4 / xxhash - Java API ${ivy.revision}"
+- destDir="${build}/docs">
++ destDir="${build}/docs"
++ encoding="UTF-8"
++ additionalparam="-Xdoclint:none">
+ <link
href="http://download.oracle.com/javase/6/docs/api/" />
+ <sourcepath>
+ <pathelement location="${src}/java"/>
+@@ -375,8 +371,12 @@
+ </jar>
+ </target>
+
+- <target name="bundle" description="makes the JAR a valid OSGi
bundle" depends="install-bnd, jar">
+- <taskdef resource="aQute/bnd/ant/taskdef.properties"
classpathref="bnd.classpath"/>
++ <target name="bundle" description="makes the JAR a valid OSGi
bundle" depends="jar">
++ <taskdef resource="aQute/bnd/ant/taskdef.properties" >
++ <classpath>
++ <fileset dir="/usr/share/java/aqute-bnd"/>
++ </classpath>
++ </taskdef>
+ <property name="packages.version"
value="${ivy.revision}"/>
+ <!-- We need to remove potential -SNAPSHOT qualifiers as package versions...
-->
+ <script language="javascript">
+@@ -411,7 +411,7 @@
+ <antcall target="dist" />
+ </target>
+
+- <target name="forbidden-apis" description="check API usage"
depends="install-forbidden-apis,compile">
++ <target name="forbidden-apis" description="check API usage"
depends="compile">
+ <forbidden-apis internalRuntimeForbidden="true"
classpathref="forbidden-apis.classpath">
+ <bundledSignatures name="jdk-unsafe-${javac.target}"/>
+ <bundledSignatures name="jdk-deprecated-${javac.target}"/>
+@@ -429,41 +429,22 @@
+ <attribute name="repositoryid" />
+ <attribute name="repositoryurl" />
+ <sequential>
+- <mvn:mvn>
+- <arg
value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"
/>
+- <arg value="-Durl=@{repositoryurl}" />
+- <arg value="-DrepositoryId=@{repositoryid}" />
+- <arg value="-DpomFile=${dist}/${ivy.module}-${ivy.revision}.pom"
/>
+- <arg value="-Dfile=${dist}/${ivy.module}-${ivy.revision}.jar"
/>
+- <arg
value="-Dfiles=${dist}/${ivy.module}-${ivy.revision}-sources.jar,${dist}/${ivy.module}-${ivy.revision}-javadoc.jar"
/>
+- <arg value="-Dclassifiers=sources,javadoc" />
+- <arg value="-Dtypes=jar,jar" />
+- <arg value="-Pgpg" />
+- </mvn:mvn>
+ </sequential>
+ </macrodef>
+
+ <target name="deploy" description="deploy snapshot to snapshot
repo" depends="install-maven-ant-tasks">
+- <property name="skip.jni" value="true" />
+- <antcall target="-deploy" />
+ </target>
+
+ <target name="-deploy" depends="clean,dist">
+- <deploy repositoryid="sonatype-nexus-snapshots"
repositoryurl="https://oss.sonatype.org/content/repositories/snapsho... />
+ </target>
+
+ <!-- before this, update project version from SNAPSHOT to RELEASE -->
+ <target name="stage" description="deploy to release repo"
depends="install-maven-ant-tasks,test-skip-jni,forbidden-apis">
+- <property name="skip.jni" value="true" />
+- <antcall target="-stage" />
+ </target>
+
+ <target name="stage-skip-test" description="deploy to release repo,
skipping tests" depends="install-maven-ant-tasks,forbidden-apis">
+- <property name="skip.jni" value="true" />
+- <antcall target="-stage" />
+ </target>
+
+ <target name="-stage" depends="clean,dist">
+- <deploy repositoryid="sonatype-nexus-staging"
repositoryurl="https://oss.sonatype.org/service/local/staging/deploy...
/>
+ </target>
+ </project>
diff --git a/1-junit_Assert.patch b/1-junit_Assert.patch
new file mode 100644
index 0000000..6b0075f
--- /dev/null
+++ b/1-junit_Assert.patch
@@ -0,0 +1,316 @@
+diff -Nru lz4-java-1.3.0/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java
+--- lz4-java-1.3.0/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java 2014-11-26
20:04:10.000000000 +0100
++++
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/lz4/LZ4BlockStreamingTest.java 2016-05-03
17:08:40.285741530 +0200
+@@ -207,11 +207,11 @@
+
+ final LZ4FastDecompressor decompressor =
LZ4Factory.fastestInstance().fastDecompressor();
+ InputStream is = new LZ4BlockInputStream(open(compressed.toByteArray()),
decompressor, checksum);
+- assertFalse(is.markSupported());
++ org.junit.Assert.assertFalse(is.markSupported());
+ try {
+ is.mark(1);
+ is.reset();
+- assertFalse(true);
++ org.junit.Assert.assertFalse(true);
+ } catch (IOException e) {
+ // OK
+ }
+@@ -235,8 +235,8 @@
+ }
+ }
+ is.close();
+- assertEquals(data.length, read);
+- assertArrayEquals(data, Arrays.copyOf(restored, read));
++ org.junit.Assert.assertEquals(data.length, read);
++ org.junit.Assert.assertArrayEquals(data, Arrays.copyOf(restored, read));
+
+ // test skip
+ final int offset = data.length <= 1 ? 0 : randomInt(data.length - 1);
+@@ -246,17 +246,17 @@
+ read = 0;
+ while (read < offset) {
+ final long skipped = is.skip(offset - read);
+- assertTrue(skipped >= 0);
++ org.junit.Assert.assertTrue(skipped >= 0);
+ read += skipped;
+ }
+ read = 0;
+ while (read < length) {
+ final int r = is.read(restored, read, length - read);
+- assertTrue(r >= 0);
++ org.junit.Assert.assertTrue(r >= 0);
+ read += r;
+ }
+ is.close();
+- assertArrayEquals(Arrays.copyOfRange(data, offset, offset + length),
Arrays.copyOfRange(restored, 0, length));
++ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, offset, offset +
length), Arrays.copyOfRange(restored, 0, length));
+ }
+
+ @Test
+@@ -288,7 +288,7 @@
+ byte[] actual = new byte[testBytes.length];
+ in.read(actual);
+
+- assertArrayEquals(testBytes, actual);
++ org.junit.Assert.assertArrayEquals(testBytes, actual);
+
+ in.close();
+ in.close();
+diff -Nru lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash32Test.java
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash32Test.java
+--- lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash32Test.java 2014-11-26
20:04:10.000000000 +0100
++++ lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash32Test.java 2016-05-03
17:08:40.278738569 +0200
+@@ -129,12 +129,12 @@
+ final int ref = XXHashFactory.nativeInstance().hash32().hash(buf, off, len, seed);
+ for (XXHash32 hash : INSTANCES) {
+ final int h = hash.hash(buf, off, len, seed);
+- assertEquals(hash.toString(), ref, h);
++ org.junit.Assert.assertEquals(hash.toString(), ref, h);
+ final ByteBuffer copy = copyOf(buf, off, len);
+ final int h2 = hash.hash(copy, off, len, seed);
+- assertEquals(off, copy.position());
+- assertEquals(len, copy.remaining());
+- assertEquals(hash.toString(), ref, h2);
++ org.junit.Assert.assertEquals(off, copy.position());
++ org.junit.Assert.assertEquals(len, copy.remaining());
++ org.junit.Assert.assertEquals(hash.toString(), ref, h2);
+ }
+ }
+
+@@ -155,8 +155,8 @@
+ hash1.update(bytes, off, len);
+ hash2.update(bytes, off, len);
+ hash3.update(bytes, off, len);
+- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
+- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
++ org.junit.Assert.assertEquals(hash2.toString() + " " + totalLen,
hash1.getValue(), hash2.getValue());
++ org.junit.Assert.assertEquals(hash3.toString() + " " + totalLen,
hash1.getValue(), hash3.getValue());
+ totalLen += len;
+ }
+ }
+diff -Nru lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash64Test.java
lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash64Test.java
+--- lz4-java-1.3.0/src/test/net/jpountz/xxhash/XXHash64Test.java 2014-11-26
20:04:10.000000000 +0100
++++ lz4-java-1.3.0.junit.Assert/src/test/net/jpountz/xxhash/XXHash64Test.java 2016-05-03
17:08:40.278738569 +0200
+@@ -134,12 +134,12 @@
+ final long ref = XXHashFactory.nativeInstance().hash64().hash(buf, off, len, seed);
+ for (XXHash64 hash : INSTANCES) {
+ final long h = hash.hash(buf, off, len, seed);
+- assertEquals(hash.toString(), ref, h);
++ org.junit.Assert.assertEquals(hash.toString(), ref, h);
+ final ByteBuffer copy = copyOf(buf, off, len);
+ final long h2 = hash.hash(copy, off, len, seed);
+- assertEquals(off, copy.position());
+- assertEquals(len, copy.remaining());
+- assertEquals(hash.toString(), ref, h2);
++ org.junit.Assert.assertEquals(off, copy.position());
++ org.junit.Assert.assertEquals(len, copy.remaining());
++ org.junit.Assert.assertEquals(hash.toString(), ref, h2);
+ }
+ }
+
+@@ -160,8 +160,8 @@
+ hash1.update(bytes, off, len);
+ hash2.update(bytes, off, len);
+ hash3.update(bytes, off, len);
+- assertEquals(hash2.toString() + " " + totalLen, hash1.getValue(),
hash2.getValue());
+- assertEquals(hash3.toString() + " " + totalLen, hash1.getValue(),
hash3.getValue());
++ org.junit.Assert.assertEquals(hash2.toString() + " " + totalLen,
hash1.getValue(), hash2.getValue());
++ org.junit.Assert.assertEquals(hash3.toString() + " " + totalLen,
hash1.getValue(), hash3.getValue());
+ totalLen += len;
+ }
+ }
+diff --git a/src/test/net/jpountz/lz4/LZ4Test.java
b/src/test/net/jpountz/lz4/LZ4Test.java
+index 739fdaf..6d27121 100644
+--- a/src/test/net/jpountz/lz4/LZ4Test.java
++++ b/src/test/net/jpountz/lz4/LZ4Test.java
+@@ -56,7 +56,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ if (tempLibFiles != null) {
+ for (File tempLibFile : tempLibFiles) {
+ File lckFile = new File(tempLibFile.getAbsolutePath() + ".lck");
+- assertTrue(tempLibFile.getAbsolutePath(), lckFile.exists());
++ org.junit.Assert.assertTrue(tempLibFile.getAbsolutePath(), lckFile.exists());
+ }
+ }
+ }
+@@ -70,7 +70,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ for (File tempLockFile : tempLockFiles) {
+ String tempLockFilePath = tempLockFile.getAbsolutePath();
+ File libFile = new File(tempLockFilePath.substring(0, tempLockFilePath.length() - 4));
+- assertTrue(tempLockFilePath, libFile.exists());
++ org.junit.Assert.assertTrue(tempLockFilePath, libFile.exists());
+ }
+ }
+ }
+@@ -80,7 +80,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ public void testMaxCompressedLength() {
+ final int len = randomBoolean() ? randomInt(16) : randomInt(1 << 30);
+ for (LZ4Compressor compressor : COMPRESSORS) {
+- assertEquals(LZ4JNI.LZ4_compressBound(len), compressor.maxCompressedLength(len));
++ org.junit.Assert.assertEquals(LZ4JNI.LZ4_compressBound(len),
compressor.maxCompressedLength(len));
+ }
+ }
+
+@@ -116,8 +116,8 @@ public class LZ4Test extends AbstractLZ4Test {
+ byte[] compressed = getCompressedWorstCase(decompressed);
+ byte[] restored = new byte[decompressed.length];
+ int cpLen = decompressor.decompress(compressed, 0, restored, 0,
decompressed.length);
+- assertEquals(compressed.length, cpLen);
+- assertArrayEquals(decompressed, restored);
++ org.junit.Assert.assertEquals(compressed.length, cpLen);
++ org.junit.Assert.assertArrayEquals(decompressed, restored);
+ }
+
+ @Test
+@@ -134,8 +134,8 @@ public class LZ4Test extends AbstractLZ4Test {
+ byte[] compressed = getCompressedWorstCase(decompressed);
+ byte[] restored = new byte[decompressed.length];
+ int uncpLen = decompressor.decompress(compressed, 0, compressed.length, restored,
0);
+- assertEquals(decompressed.length, uncpLen);
+- assertArrayEquals(decompressed, restored);
++ org.junit.Assert.assertEquals(decompressed.length, uncpLen);
++ org.junit.Assert.assertArrayEquals(decompressed, restored);
+ }
+
+ @Test
+@@ -169,8 +169,8 @@ public class LZ4Test extends AbstractLZ4Test {
+
+ // test decompression
+ final T restored = tester.allocate(len);
+- assertEquals(compressedLen, tester.decompress(decompressor, compressed, 0, restored,
0, len));
+- assertArrayEquals(Arrays.copyOfRange(data, off, off + len), tester.copyOf(restored,
0, len));
++ org.junit.Assert.assertEquals(compressedLen, tester.decompress(decompressor,
compressed, 0, restored, 0, len));
++ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
+
+ // make sure it fails if the compression dest is not large enough
+ tester.fill(restored, randomByte());
+@@ -183,8 +183,8 @@ public class LZ4Test extends AbstractLZ4Test {
+ // because the compressor is allowed to return different compression results
+ // even when it is invoked with the same input data.
+ // In this case, just make sure the compressed data can be successfully
decompressed.
+- assertEquals(compressedLen2, tester.decompress(decompressor, compressed2, 0,
restored, 0, len));
+- assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
++ org.junit.Assert.assertEquals(compressedLen2, tester.decompress(decompressor,
compressed2, 0, restored, 0, len));
++ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -194,7 +194,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ // decompression dest is too small
+ try {
+ tester.decompress(decompressor, compressed, 0, restored, 0, len - 1);
+- fail();
++ org.junit.Assert.fail();
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -204,7 +204,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ final T restored2 = tester.allocate(len+1);
+ try {
+ final int cpLen = tester.decompress(decompressor, compressed, 0, restored2, 0, len +
1);
+- fail("compressedLen=" + cpLen);
++ org.junit.Assert.fail("compressedLen=" + cpLen);
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -212,17 +212,17 @@ public class LZ4Test extends AbstractLZ4Test {
+ // try decompression when only the size of the compressed buffer is known
+ if (len > 0) {
+ tester.fill(restored, randomByte());
+- assertEquals(len, tester.decompress(decompressor2, compressed, 0, compressedLen,
restored, 0, len));
+- assertArrayEquals(Arrays.copyOfRange(data, off, off + len), tester.copyOf(restored, 0,
len));
++ org.junit.Assert.assertEquals(len, tester.decompress(decompressor2, compressed, 0,
compressedLen, restored, 0, len));
++ org.junit.Assert.assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
tester.copyOf(restored, 0, len));
+ tester.fill(restored, randomByte());
+ } else {
+- assertEquals(0, tester.decompress(decompressor2, compressed, 0, compressedLen,
tester.allocate(1), 0, 1));
++ org.junit.Assert.assertEquals(0, tester.decompress(decompressor2, compressed, 0,
compressedLen, tester.allocate(1), 0, 1));
+ }
+
+ // over-estimated compressed length
+ try {
+ final int decompressedLen = tester.decompress(decompressor2, compressed, 0,
compressedLen + 1, tester.allocate(len + 100), 0, len + 100);
+- fail("decompressedLen=" + decompressedLen);
++ org.junit.Assert.fail("decompressedLen=" + decompressedLen);
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -231,7 +231,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ try {
+ final int decompressedLen = tester.decompress(decompressor2, compressed, 0,
compressedLen - 1, tester.allocate(len + 100), 0, len + 100);
+ if (!(decompressor2 instanceof LZ4JNISafeDecompressor)) {
+- fail("decompressedLen=" + decompressedLen);
++ org.junit.Assert.fail("decompressedLen=" + decompressedLen);
+ }
+ } catch (LZ4Exception e) {
+ // OK
+@@ -307,7 +307,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ try {
+ // it is invalid to end with a match, should be at least 5 literals
+ decompressor.decompress(invalid, 0, new byte[decompressedLength], 0,
decompressedLength);
+- assertTrue(decompressor.toString(), false);
++ org.junit.Assert.assertTrue(decompressor.toString(), false);
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -317,7 +317,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ try {
+ // it is invalid to end with a match, should be at least 5 literals
+ decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
+- assertTrue(false);
++ org.junit.Assert.assertTrue(false);
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -337,7 +337,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ try {
+ // it is invalid to end with a match, should be at least 5 literals
+ decompressor.decompress(invalid, 0, new byte[20], 0, 20);
+- assertTrue(decompressor.toString(), false);
++ org.junit.Assert.assertTrue(decompressor.toString(), false);
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -347,7 +347,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ try {
+ // it is invalid to end with a match, should be at least 5 literals
+ decompressor.decompress(invalid, 0, invalid.length, new byte[20], 0);
+- assertTrue(false);
++ org.junit.Assert.assertTrue(false);
+ } catch (LZ4Exception e) {
+ // OK
+ }
+@@ -362,7 +362,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
+ try {
+ compressor.compress(in, out);
+- fail();
++ org.junit.Assert.fail();
+ } catch (ReadOnlyBufferException e) {
+ // ok
+ }
+@@ -372,7 +372,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ ByteBuffer out = Tester.BYTE_BUFFER.allocate(100).asReadOnlyBuffer();
+ try {
+ decompressor.decompress(in, out);
+- fail();
++ org.junit.Assert.fail();
+ } catch (ReadOnlyBufferException e) {
+ // ok
+ }
+@@ -383,7 +383,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ out.limit(2);
+ try {
+ decompressor.decompress(in, out);
+- fail();
++ org.junit.Assert.fail();
+ } catch (ReadOnlyBufferException e) {
+ // ok
+ }
+@@ -486,7 +486,7 @@ public class LZ4Test extends AbstractLZ4Test {
+ }
+ final Sequence sequence1 = readSequence(expected, off);
+ final Sequence sequence2 = readSequence(actual, off);
+- assertEquals(message + ", off=" + off + ", decompressedOff=" +
decompressedOff, sequence1, sequence2);
++ org.junit.Assert.assertEquals(message + ", off=" + off + ",
decompressedOff=" + decompressedOff, sequence1, sequence2);
+ off += sequence1.length;
+ decompressedOff += sequence1.literalLen + sequence1.matchLen;
+ }
diff --git a/lz4-java.spec b/lz4-java.spec
index e989247..c0587ed 100644
--- a/lz4-java.spec
+++ b/lz4-java.spec
@@ -4,8 +4,8 @@
%global build_opts -Doffline=true -Divy.mode=local
-Divysettings.xml=/etc/ivy/ivysettings.xml -Divy.revision=%{version}
Name: lz4-java
-Version: 1.3.0
-Release: 13%{?dist}
+Version: 1.7.1
+Release: 1%{?dist}
Summary: LZ4 compression for Java
# GPL: src/xxhash/bench.c
# src/lz4/programs
@@ -18,9 +18,9 @@ Source0:
https://github.com/jpountz/lz4-java/archive/%{version}.tar.gz
# Disable maven-ant-tasks and old aqute-bnd (1.50.x) support
# Add support for system mvel2
# Fix doclint/encoding in javadoc task
-Patch0: lz4-java-1.3.0-build.patch
+Patch0: 0-build.patch
# Use randomizedtesting <= 2.1.3
-Patch1: lz4-java-1.3.0-junit_Assert.patch
+Patch1: 1-junit_Assert.patch
# Build tools
BuildRequires: ant
@@ -83,9 +83,6 @@ find -name '*.so' -print -delete
%patch0 -p1
%patch1 -p1
-cp -p src/xxhash/LICENSE LICENSE.xxhash
-cp -p src/lz4/LICENSE lz4_LICENSE
-
# Fix OSGi manifest entries
echo "Export-Package: net.jpountz.*,!linux.*" >> lz4.bnd
sed -i '/packages.version/d' lz4.bnd
@@ -118,6 +115,9 @@ ant %build_opts test
%license LICENSE.txt
%changelog
+* Thu Jul 30 2020 Alex Macdonald <almacdon(a)redhat.com> 1.7.1-1
+- Update to version 1.7.1
+
* Wed Jan 29 2020 Fedora Release Engineering <releng(a)fedoraproject.org> - 1.3.0-13
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
diff --git a/sources b/sources
index 678213a..971053e 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-b9a4eb57fd0667df96135854c9e6f139 1.3.0.tar.gz
+SHA512 (1.7.1.tar.gz) =
13fd89a9564f1f504348ce30a51ca22d5581a6661658d55c96f3f0c1e43126de04d2df87683251a8ec5bf53726f529b60bb1ec666863b7e33810df8ed73bb586