diff --git a/src/java/net/jpountz/lz4/LZ4JNI.java b/src/java/net/jpountz/lz4/LZ4JNI.java index a25fd99c..f083319a 100644 --- a/src/java/net/jpountz/lz4/LZ4JNI.java +++ b/src/java/net/jpountz/lz4/LZ4JNI.java @@ -31,7 +31,7 @@ enum LZ4JNI { } static native void init(); - static native int LZ4_compress(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen); + static native int LZ4_compress_limitedOutput(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen); static native int LZ4_compressHC(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen, int compressionLevel); static native int LZ4_decompress_fast(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, byte[] destArray, ByteBuffer destBuffer, int destOff, int destLen); static native int LZ4_decompress_safe(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen); diff --git a/src/java/net/jpountz/lz4/LZ4JNICompressor.java b/src/java/net/jpountz/lz4/LZ4JNICompressor.java index a25e450f..18971a33 100644 --- a/src/java/net/jpountz/lz4/LZ4JNICompressor.java +++ b/src/java/net/jpountz/lz4/LZ4JNICompressor.java @@ -33,7 +33,7 @@ final class LZ4JNICompressor extends LZ4Compressor { public int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen) { checkRange(src, srcOff, srcLen); checkRange(dest, destOff, maxDestLen); - final int result = LZ4JNI.LZ4_compress(src, null, srcOff, srcLen, dest, null, destOff, maxDestLen); + final int result = LZ4JNI.LZ4_compress_limitedOutput(src, null, srcOff, srcLen, dest, null, destOff, maxDestLen); if (result <= 0) { throw new LZ4Exception("maxDestLen is too small"); } @@ -64,7 +64,7 @@ public int compress(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dest, int destBuf = dest; } - final int result = LZ4JNI.LZ4_compress(srcArr, srcBuf, srcOff, srcLen, destArr, destBuf, destOff, maxDestLen); + final int result = LZ4JNI.LZ4_compress_limitedOutput(srcArr, srcBuf, srcOff, srcLen, destArr, destBuf, destOff, maxDestLen); if (result <= 0) { throw new LZ4Exception("maxDestLen is too small"); } diff --git a/src/jni/net_jpountz_lz4_LZ4JNI.c b/src/jni/net_jpountz_lz4_LZ4JNI.c index b4c7bd89..44c30d9f 100644 --- a/src/jni/net_jpountz_lz4_LZ4JNI.c +++ b/src/jni/net_jpountz_lz4_LZ4JNI.c @@ -34,10 +34,14 @@ static void throw_OOM(JNIEnv *env) { /* * Class: net_jpountz_lz4_LZ4JNI - * Method: LZ4_compress + * Method: LZ4_compress_limitedOutput * Signature: ([BLjava/nio/ByteBuffer;II[BLjava/nio/ByteBuffer;II)I + * + * Though LZ4_compress_limitedOutput is no longer called as it was deprecated, + * keep the method name of LZ4_compress_limitedOutput for backward compatibility, + * so that the old JNI bindings in src/resources can still be used. */ -JNIEXPORT jint JNICALL Java_net_jpountz_lz4_LZ4JNI_LZ4_1compress +JNIEXPORT jint JNICALL Java_net_jpountz_lz4_LZ4JNI_LZ4_1compress_1limitedOutput (JNIEnv *env, jclass cls, jbyteArray srcArray, jobject srcBuffer, jint srcOff, jint srcLen, jbyteArray destArray, jobject destBuffer, jint destOff, jint maxDestLen) { char* in;