diff --git a/src/build/source_templates/xxhash64_streaming.template b/src/build/source_templates/xxhash64_streaming.template index 2789ae0a..205d5ff7 100644 --- a/src/build/source_templates/xxhash64_streaming.template +++ b/src/build/source_templates/xxhash64_streaming.template @@ -58,7 +58,7 @@ final class StreamingXXHash64Java${type} extends AbstractStreamingXXHash64Java { int off = 0; while (off <= memSize - 8) { long k1 = readLongLE(memory, off); - k1 *= PRIME64_2; k1 = rotateLeft(k1, 31); k1 *= PRIME64_1; h64 ^= k1; + k1 *= PRIME64_2; k1 = rotateLeft(k1, 31); k1 *= PRIME64_1; h64 ^= k1; h64 = rotateLeft(h64, 27) * PRIME64_1 + PRIME64_4; off += 8; } diff --git a/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java b/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java index 36e8f59b..1eef29c1 100644 --- a/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java +++ b/src/java-unsafe/net/jpountz/lz4/LZ4UnsafeUtils.java @@ -55,34 +55,34 @@ static void wildArraycopy(byte[] src, int srcOff, byte[] dest, int destOff, int 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)); + 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; + 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; diff --git a/src/java-unsafe/net/jpountz/util/UnsafeUtils.java b/src/java-unsafe/net/jpountz/util/UnsafeUtils.java index 1af5cb0d..d6016576 100644 --- a/src/java-unsafe/net/jpountz/util/UnsafeUtils.java +++ b/src/java-unsafe/net/jpountz/util/UnsafeUtils.java @@ -33,7 +33,7 @@ public enum UnsafeUtils { 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"); diff --git a/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java b/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java index 623eb1c6..96e0a360 100644 --- a/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java +++ b/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java @@ -228,7 +228,7 @@ private void flushBufferedData() throws IOException { /** * Flushes this compressed {@link OutputStream}. - * + *
* If the stream has been created with syncFlush=true, pending
* data will be compressed and appended to the underlying {@link OutputStream}
* before calling {@link OutputStream#flush()} on the underlying stream.
diff --git a/src/java/net/jpountz/lz4/LZ4ByteBufferUtils.java b/src/java/net/jpountz/lz4/LZ4ByteBufferUtils.java
index 9fe63d7d..f6c57168 100644
--- a/src/java/net/jpountz/lz4/LZ4ByteBufferUtils.java
+++ b/src/java/net/jpountz/lz4/LZ4ByteBufferUtils.java
@@ -36,6 +36,7 @@
enum LZ4ByteBufferUtils {
;
+
static int hash(ByteBuffer buf, int i) {
return LZ4Utils.hash(readInt(buf, i));
}
@@ -57,34 +58,34 @@ static void safeIncrementalCopy(ByteBuffer dest, int matchOff, int dOff, int mat
static void wildIncrementalCopy(ByteBuffer 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));
+ 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;
+ 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;
diff --git a/src/java/net/jpountz/lz4/LZ4Compressor.java b/src/java/net/jpountz/lz4/LZ4Compressor.java
index e9e72b3b..087f47de 100644
--- a/src/java/net/jpountz/lz4/LZ4Compressor.java
+++ b/src/java/net/jpountz/lz4/LZ4Compressor.java
@@ -41,7 +41,7 @@ public final int maxCompressedLength(int length) {
* Compresses src[srcOff:srcOff+srcLen] into
* dest[destOff:destOff+maxDestLen] and returns the compressed
* length.
- *
+ *
* This method will throw a {@link LZ4Exception} if this compressor is unable
* to compress the input into less than maxDestLen bytes. To
* prevent this exception to be thrown, you should make sure that
@@ -62,12 +62,12 @@ public final int maxCompressedLength(int length) {
* Compresses src[srcOff:srcOff+srcLen] into
* dest[destOff:destOff+maxDestLen] and returns the compressed
* length.
- *
+ *
* This method will throw a {@link LZ4Exception} if this compressor is unable
* to compress the input into less than maxDestLen bytes. To
* prevent this exception to be thrown, you should make sure that
* maxDestLen >= maxCompressedLength(srcLen).
- *
+ *
* {@link ByteBuffer} positions remain unchanged.
*
* @param src the source data
diff --git a/src/java/net/jpountz/lz4/LZ4CompressorWithLength.java b/src/java/net/jpountz/lz4/LZ4CompressorWithLength.java
index e52ae1ee..3a2d566e 100644
--- a/src/java/net/jpountz/lz4/LZ4CompressorWithLength.java
+++ b/src/java/net/jpountz/lz4/LZ4CompressorWithLength.java
@@ -43,17 +43,17 @@ public LZ4CompressorWithLength(LZ4Compressor compressor) {
}
private void putOriginalLength(byte[] dest, int destOff, int originalLength) {
- dest[destOff] = (byte)originalLength;
- dest[destOff + 1] = (byte)(originalLength >> 8);
- dest[destOff + 2] = (byte)(originalLength >> 16);
- dest[destOff + 3] = (byte)(originalLength >> 24);
+ dest[destOff] = (byte) originalLength;
+ dest[destOff + 1] = (byte) (originalLength >> 8);
+ dest[destOff + 2] = (byte) (originalLength >> 16);
+ dest[destOff + 3] = (byte) (originalLength >> 24);
}
private void putOriginalLength(ByteBuffer dest, int destOff, int originalLength) {
- dest.put(destOff, (byte)originalLength);
- dest.put(destOff + 1, (byte)(originalLength >> 8));
- dest.put(destOff + 2, (byte)(originalLength >> 16));
- dest.put(destOff + 3, (byte)(originalLength >> 24));
+ dest.put(destOff, (byte) originalLength);
+ dest.put(destOff + 1, (byte) (originalLength >> 8));
+ dest.put(destOff + 2, (byte) (originalLength >> 16));
+ dest.put(destOff + 3, (byte) (originalLength >> 24));
}
/**
@@ -137,7 +137,7 @@ public int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff
* Compresses src[srcOff:srcOff+srcLen] into
* dest[destOff:destOff+maxDestLen] and returns the compressed
* length.
- *
+ *
* This method will throw a {@link LZ4Exception} if this compressor is unable
* to compress the input into less than maxDestLen bytes. To
* prevent this exception to be thrown, you should make sure that
@@ -176,12 +176,12 @@ public void compress(ByteBuffer src, ByteBuffer dest) {
* Compresses src[srcOff:srcOff+srcLen] into
* dest[destOff:destOff+maxDestLen] and returns the compressed
* length.
- *
+ *
* This method will throw a {@link LZ4Exception} if this compressor is unable
* to compress the input into less than maxDestLen bytes. To
* prevent this exception to be thrown, you should make sure that
* maxDestLen >= maxCompressedLength(srcLen).
- *
+ *
* {@link ByteBuffer} positions remain unchanged.
*
* @param src the source data
diff --git a/src/java/net/jpountz/lz4/LZ4Constants.java b/src/java/net/jpountz/lz4/LZ4Constants.java
index 5f776d03..3f33b37c 100644
--- a/src/java/net/jpountz/lz4/LZ4Constants.java
+++ b/src/java/net/jpountz/lz4/LZ4Constants.java
@@ -20,8 +20,8 @@
enum LZ4Constants {
;
- static final int DEFAULT_COMPRESSION_LEVEL = 8+1;
- static final int MAX_COMPRESSION_LEVEL = 16+1;
+ static final int DEFAULT_COMPRESSION_LEVEL = 8 + 1;
+ static final int MAX_COMPRESSION_LEVEL = 16 + 1;
static final int MEMORY_USAGE = 14;
static final int NOT_COMPRESSIBLE_DETECTION_LEVEL = 6;
diff --git a/src/java/net/jpountz/lz4/LZ4DecompressorWithLength.java b/src/java/net/jpountz/lz4/LZ4DecompressorWithLength.java
index a89413cd..ec371020 100644
--- a/src/java/net/jpountz/lz4/LZ4DecompressorWithLength.java
+++ b/src/java/net/jpountz/lz4/LZ4DecompressorWithLength.java
@@ -229,7 +229,8 @@ public void decompress(ByteBuffer src, ByteBuffer dest) {
}
}
- /** When {@link LZ4FastDecompressor} was specified to the constructor,
+ /**
+ * When {@link LZ4FastDecompressor} was specified to the constructor,
* decompresses
* Please note that this instance has some traps you should be aware of:src[srcOff:] into dest[destOff:]
* and returns the number of bytes read from src, and
* when {@link LZ4SafeDecompressor} was specified to the constructor,
diff --git a/src/java/net/jpountz/lz4/LZ4Factory.java b/src/java/net/jpountz/lz4/LZ4Factory.java
index e4f2e97f..6110b2cc 100644
--- a/src/java/net/jpountz/lz4/LZ4Factory.java
+++ b/src/java/net/jpountz/lz4/LZ4Factory.java
@@ -23,6 +23,7 @@
import net.jpountz.util.Native;
import net.jpountz.util.Utils;
+
import static net.jpountz.lz4.LZ4Constants.DEFAULT_COMPRESSION_LEVEL;
import static net.jpountz.lz4.LZ4Constants.MAX_COMPRESSION_LEVEL;
@@ -231,22 +232,22 @@ private static src[srcOff:] into dest[destOff:destOff+destLen]
+ /**
+ * Decompresses src[srcOff:] into dest[destOff:destOff+destLen]
* and returns the number of bytes read from src.
* destLen must be exactly the size of the decompressed data.
*
@@ -47,7 +48,8 @@ public abstract class LZ4FastDecompressor implements LZ4Decompressor {
*/
public abstract int decompress(byte[] src, int srcOff, byte[] dest, int destOff, int destLen);
- /** Decompresses src[srcOff:] into dest[destOff:destOff+destLen]
+ /**
+ * Decompresses src[srcOff:] into dest[destOff:destOff+destLen]
* and returns the number of bytes read from src.
* destLen must be exactly the size of the decompressed data.
* The positions and limits of the {@link ByteBuffer}s remain unchanged.
diff --git a/src/java/net/jpountz/lz4/LZ4FrameInputStream.java b/src/java/net/jpountz/lz4/LZ4FrameInputStream.java
index 0c1f18ee..a86af764 100644
--- a/src/java/net/jpountz/lz4/LZ4FrameInputStream.java
+++ b/src/java/net/jpountz/lz4/LZ4FrameInputStream.java
@@ -70,7 +70,7 @@ public class LZ4FrameInputStream extends FilterInputStream {
* @param in the stream to decompress
* @throws IOException if an I/O error occurs
*
- * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32)
+ * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32)
* @see LZ4Factory#fastestInstance()
* @see XXHashFactory#fastestInstance()
*/
@@ -85,7 +85,7 @@ public LZ4FrameInputStream(InputStream in) throws IOException {
* @param readSingleFrame whether read is stopped after the first non-skippable frame
* @throws IOException if an I/O error occurs
*
- * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32)
+ * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32)
* @see LZ4Factory#fastestInstance()
* @see XXHashFactory#fastestInstance()
*/
@@ -102,9 +102,9 @@ public LZ4FrameInputStream(InputStream in, boolean readSingleFrame) throws IOExc
* @param checksum the hash function to use
* @throws IOException if an I/O error occurs
*
- * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32, boolean)
+ * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32, boolean)
*/
- public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum) throws IOException {
+ public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum) throws IOException {
this(in, decompressor, checksum, false);
}
@@ -117,7 +117,7 @@ public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XX
* @param readSingleFrame whether read is stopped after the first non-skippable frame
* @throws IOException if an I/O error occurs
*/
- public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame) throws IOException {
+ public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame) throws IOException {
super(in);
this.decompressor = decompressor;
this.checksum = checksum;
@@ -128,6 +128,7 @@ public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XX
/**
* Try and load in the next valid frame info. This will skip over skippable frames.
+ *
* @return True if a frame was loaded. False if there are no more frames in the stream.
* @throws IOException On input stream read exception
*/
@@ -135,8 +136,8 @@ private boolean nextFrameInfo() throws IOException {
while (true) {
int size = 0;
do {
- final int mySize = in.read(readNumberBuff.array(), size, LZ4FrameOutputStream.INTEGER_BYTES - size);
- if (mySize < 0) {
+ final int mySize = in.read(readNumberBuff.array(), size, LZ4FrameOutputStream.INTEGER_BYTES - size);
+ if (mySize < 0) {
if (firstFrameHeaderRead) {
if (size > 0) {
throw new IOException(PREMATURE_EOS);
@@ -146,17 +147,17 @@ private boolean nextFrameInfo() throws IOException {
} else {
throw new IOException(PREMATURE_EOS);
}
- }
- size += mySize;
+ }
+ size += mySize;
} while (size < LZ4FrameOutputStream.INTEGER_BYTES);
final int magic = readNumberBuff.getInt(0);
if (magic == LZ4FrameOutputStream.MAGIC) {
- readHeader();
- return true;
+ readHeader();
+ return true;
} else if ((magic >>> 4) == (MAGIC_SKIPPABLE_BASE >>> 4)) {
- skippableFrame();
+ skippableFrame();
} else {
- throw new IOException(NOT_SUPPORTED);
+ throw new IOException(NOT_SUPPORTED);
}
}
}
@@ -191,10 +192,10 @@ private void readHeader() throws IOException {
throw new IOException(PREMATURE_EOS);
}
- final byte flgByte = (byte)(flgRead & 0xFF);
+ final byte flgByte = (byte) (flgRead & 0xFF);
final LZ4FrameOutputStream.FLG flg = LZ4FrameOutputStream.FLG.fromByte(flgByte);
headerBuffer.put(flgByte);
- final byte bdByte = (byte)(bdRead & 0xFF);
+ final byte bdByte = (byte) (bdRead & 0xFF);
final LZ4FrameOutputStream.BD bd = LZ4FrameOutputStream.BD.fromByte(bdByte);
headerBuffer.put(bdByte);
@@ -213,7 +214,7 @@ private void readHeader() throws IOException {
throw new IOException(PREMATURE_EOS);
}
- if (hash != (byte)(expectedHash & 0xFF)) {
+ if (hash != (byte) (expectedHash & 0xFF)) {
throw new IOException(DESCRIPTOR_HASH_MISMATCH);
}
@@ -271,7 +272,7 @@ private void readBlock() throws IOException {
}
}
if (frameInfo.isEnabled(LZ4FrameOutputStream.FLG.Bits.CONTENT_SIZE) && expectedContentSize != totalContentSize) {
- throw new IOException("Size check mismatch");
+ throw new IOException("Size check mismatch");
}
frameInfo.finish();
return;
@@ -329,13 +330,13 @@ public int read() throws IOException {
if (firstFrameHeaderRead && readSingleFrame) {
return -1;
}
- if (!nextFrameInfo()) {
- return -1;
- }
+ if (!nextFrameInfo()) {
+ return -1;
+ }
}
readBlock();
}
- return (int)buffer.get() & 0xFF;
+ return (int) buffer.get() & 0xFF;
}
@Override
@@ -348,9 +349,9 @@ public int read(byte[] b, int off, int len) throws IOException {
if (firstFrameHeaderRead && readSingleFrame) {
return -1;
}
- if (!nextFrameInfo()) {
- return -1;
- }
+ if (!nextFrameInfo()) {
+ return -1;
+ }
}
readBlock();
}
@@ -369,14 +370,14 @@ public long skip(long n) throws IOException {
if (firstFrameHeaderRead && readSingleFrame) {
return 0;
}
- if (!nextFrameInfo()) {
- return 0;
- }
+ if (!nextFrameInfo()) {
+ return 0;
+ }
}
readBlock();
}
n = Math.min(n, buffer.remaining());
- buffer.position(buffer.position() + (int)n);
+ buffer.position(buffer.position() + (int) n);
return n;
}
@@ -413,7 +414,7 @@ public boolean markSupported() {
* @return the expected content size, or -1L if no expected content size is set in the frame.
* @throws IOException On input stream read exception
*
- * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32, boolean)
+ * @see #LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32, boolean)
*/
public long getExpectedContentSize() throws IOException {
if (!readSingleFrame) {
@@ -421,7 +422,7 @@ public long getExpectedContentSize() throws IOException {
}
if (!firstFrameHeaderRead) {
if (!nextFrameInfo()) {
- return -1L;
+ return -1L;
}
}
return expectedContentSize;
@@ -436,9 +437,9 @@ public long getExpectedContentSize() throws IOException {
public boolean isExpectedContentSizeDefined() throws IOException {
if (readSingleFrame) {
if (!firstFrameHeaderRead) {
- if (!nextFrameInfo()) {
- return false;
- }
+ if (!nextFrameInfo()) {
+ return false;
+ }
}
return expectedContentSize >= 0;
} else {
diff --git a/src/java/net/jpountz/lz4/LZ4FrameOutputStream.java b/src/java/net/jpountz/lz4/LZ4FrameOutputStream.java
index a8382fde..42a85463 100644
--- a/src/java/net/jpountz/lz4/LZ4FrameOutputStream.java
+++ b/src/java/net/jpountz/lz4/LZ4FrameOutputStream.java
@@ -64,14 +64,17 @@ public class LZ4FrameOutputStream extends FilterOutputStream {
public static enum BLOCKSIZE {
SIZE_64KB(4), SIZE_256KB(5), SIZE_1MB(6), SIZE_4MB(7);
private final int indicator;
+
BLOCKSIZE(int indicator) {
this.indicator = indicator;
}
+
public int getIndicator() {
return this.indicator;
}
+
public static BLOCKSIZE valueOf(int indicator) {
- switch(indicator) {
+ switch (indicator) {
case 7: return SIZE_4MB;
case 6: return SIZE_1MB;
case 5: return SIZE_256KB;
@@ -117,7 +120,7 @@ public LZ4FrameOutputStream(OutputStream out, BLOCKSIZE blockSize, FLG.Bits... b
*/
public LZ4FrameOutputStream(OutputStream out, BLOCKSIZE blockSize, long knownSize, FLG.Bits... bits) throws IOException {
this(out, blockSize, knownSize, LZ4Factory.fastestInstance().fastCompressor(),
- XXHashFactory.fastestInstance().hash32(), bits);
+ XXHashFactory.fastestInstance().hash32(), bits);
}
/**
@@ -322,6 +325,7 @@ public enum Bits {
BLOCK_INDEPENDENCE(5);
private final int position;
+
Bits(int position) {
this.position = position;
}
@@ -345,12 +349,12 @@ private FLG(int version, byte b) {
}
public static FLG fromByte(byte flg) {
- final byte versionMask = (byte)(flg & (3 << 6));
+ final byte versionMask = (byte) (flg & (3 << 6));
return new FLG(versionMask >>> 6, (byte) (flg ^ versionMask));
}
public byte toByte() {
- return (byte)(bitSet.toByteArray()[0] | ((version & 3) << 6));
+ return (byte) (bitSet.toByteArray()[0] | ((version & 3) << 6));
}
private void validate() {
diff --git a/src/java/net/jpountz/lz4/LZ4SafeDecompressor.java b/src/java/net/jpountz/lz4/LZ4SafeDecompressor.java
index 71938c9a..92792c34 100644
--- a/src/java/net/jpountz/lz4/LZ4SafeDecompressor.java
+++ b/src/java/net/jpountz/lz4/LZ4SafeDecompressor.java
@@ -140,6 +140,7 @@ public final byte[] decompress(byte[] src, int maxDestLen) {
* Decompresses src into dest. src's
* {@link ByteBuffer#remaining()} must be exactly the size of the compressed
* data. This method moves the positions of the buffers.
+ *
* @param src the compressed data
* @param dest the destination buffer to store the decompressed data
* @throws LZ4Exception if dest is too small
diff --git a/src/java/net/jpountz/lz4/LZ4SafeUtils.java b/src/java/net/jpountz/lz4/LZ4SafeUtils.java
index 59bb3dd4..1d62b991 100644
--- a/src/java/net/jpountz/lz4/LZ4SafeUtils.java
+++ b/src/java/net/jpountz/lz4/LZ4SafeUtils.java
@@ -38,7 +38,7 @@ static int hash64k(byte[] buf, int i) {
}
static boolean readIntEquals(byte[] buf, int i, int j) {
- return buf[i] == buf[j] && buf[i+1] == buf[j+1] && buf[i+2] == buf[j+2] && buf[i+3] == buf[j+3];
+ return buf[i] == buf[j] && buf[i + 1] == buf[j + 1] && buf[i + 2] == buf[j + 2] && buf[i + 3] == buf[j + 3];
}
static void safeIncrementalCopy(byte[] dest, int matchOff, int dOff, int matchLen) {
diff --git a/src/java/net/jpountz/util/ByteBufferUtils.java b/src/java/net/jpountz/util/ByteBufferUtils.java
index 72bad9fb..1ab5a133 100644
--- a/src/java/net/jpountz/util/ByteBufferUtils.java
+++ b/src/java/net/jpountz/util/ByteBufferUtils.java
@@ -104,6 +104,6 @@ public static void checkNotReadOnly(ByteBuffer buffer) {
}
public static int readShortLE(ByteBuffer buf, int i) {
- return (buf.get(i) & 0xFF) | ((buf.get(i+1) & 0xFF) << 8);
+ return (buf.get(i) & 0xFF) | ((buf.get(i + 1) & 0xFF) << 8);
}
}
diff --git a/src/java/net/jpountz/util/Native.java b/src/java/net/jpountz/util/Native.java
index 048dda57..b54c79da 100644
--- a/src/java/net/jpountz/util/Native.java
+++ b/src/java/net/jpountz/util/Native.java
@@ -53,7 +53,7 @@ private static OS os() {
return OS.SOLARIS;
} else {
throw new UnsupportedOperationException("Unsupported operating system: "
- + osName);
+ + osName);
}
}
@@ -75,22 +75,24 @@ private static void cleanupOldTempLibs() {
File dir = new File(tempFolder);
File[] tempLibFiles = dir.listFiles(new FilenameFilter() {
- private final String searchPattern = "liblz4-java-";
- public boolean accept(File dir, String name) {
- return name.startsWith(searchPattern) && !name.endsWith(".lck");
- }
- });
- if(tempLibFiles != null) {
- for(File tempLibFile : tempLibFiles) {
- File lckFile = new File(tempLibFile.getAbsolutePath() + ".lck");
- if(!lckFile.exists()) {
- try {
- tempLibFile.delete();
- }
- catch(SecurityException e) {
- System.err.println("Failed to delete old temp lib" + e.getMessage());
- }
- }
+ private final String searchPattern = "liblz4-java-";
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.startsWith(searchPattern) && !name.endsWith(".lck");
+ }
+ });
+
+ if (tempLibFiles != null) {
+ for (File tempLibFile : tempLibFiles) {
+ File lckFile = new File(tempLibFile.getAbsolutePath() + ".lck");
+ if (!lckFile.exists()) {
+ try {
+ tempLibFile.delete();
+ } catch (SecurityException e) {
+ System.err.println("Failed to delete old temp lib: " + e.getMessage());
+ }
+ }
}
}
}
@@ -125,14 +127,14 @@ public static synchronized void load() {
tempLib = new File(tempLibLock.getAbsolutePath().replaceFirst(".lck$", ""));
// copy to tempLib
try (FileOutputStream out = new FileOutputStream(tempLib)) {
- byte[] buf = new byte[4096];
- while (true) {
- int read = is.read(buf);
- if (read == -1) {
- break;
- }
- out.write(buf, 0, read);
- }
+ byte[] buf = new byte[4096];
+ while (true) {
+ int read = is.read(buf);
+ if (read == -1) {
+ break;
+ }
+ out.write(buf, 0, read);
+ }
}
System.load(tempLib.getAbsolutePath());
loaded = true;
@@ -140,23 +142,23 @@ public static synchronized void load() {
throw new ExceptionInInitializerError("Cannot unpack liblz4-java: " + e);
} finally {
if (!loaded) {
- if (tempLib != null && tempLib.exists()) {
- if (!tempLib.delete()) {
- throw new ExceptionInInitializerError("Cannot unpack liblz4-java / cannot delete a temporary native library " + tempLib);
- }
- }
- if (tempLibLock != null && tempLibLock.exists()) {
- if (!tempLibLock.delete()) {
- throw new ExceptionInInitializerError("Cannot unpack liblz4-java / cannot delete a temporary lock file " + tempLibLock);
- }
- }
+ if (tempLib != null && tempLib.exists()) {
+ if (!tempLib.delete()) {
+ throw new ExceptionInInitializerError("Cannot unpack liblz4-java / cannot delete a temporary native library " + tempLib);
+ }
+ }
+ if (tempLibLock != null && tempLibLock.exists()) {
+ if (!tempLibLock.delete()) {
+ throw new ExceptionInInitializerError("Cannot unpack liblz4-java / cannot delete a temporary lock file " + tempLibLock);
+ }
+ }
} else {
final String keepEnv = System.getenv("LZ4JAVA_KEEP_TEMP_JNI_LIB");
final String keepProp = System.getProperty("lz4java.jnilib.temp.keep");
if ((keepEnv == null || !keepEnv.equals("true")) &&
(keepProp == null || !keepProp.equals("true")))
tempLib.deleteOnExit();
- tempLibLock.deleteOnExit();
+ tempLibLock.deleteOnExit();
}
}
}
diff --git a/src/java/net/jpountz/util/SafeUtils.java b/src/java/net/jpountz/util/SafeUtils.java
index d371688f..7f8449a2 100644
--- a/src/java/net/jpountz/util/SafeUtils.java
+++ b/src/java/net/jpountz/util/SafeUtils.java
@@ -47,11 +47,11 @@ public static byte readByte(byte[] buf, int i) {
}
public static int readIntBE(byte[] buf, int i) {
- return ((buf[i] & 0xFF) << 24) | ((buf[i+1] & 0xFF) << 16) | ((buf[i+2] & 0xFF) << 8) | (buf[i+3] & 0xFF);
+ return ((buf[i] & 0xFF) << 24) | ((buf[i + 1] & 0xFF) << 16) | ((buf[i + 2] & 0xFF) << 8) | (buf[i + 3] & 0xFF);
}
public static int readIntLE(byte[] buf, int i) {
- return (buf[i] & 0xFF) | ((buf[i+1] & 0xFF) << 8) | ((buf[i+2] & 0xFF) << 16) | ((buf[i+3] & 0xFF) << 24);
+ return (buf[i] & 0xFF) | ((buf[i + 1] & 0xFF) << 8) | ((buf[i + 2] & 0xFF) << 16) | ((buf[i + 3] & 0xFF) << 24);
}
public static int readInt(byte[] buf, int i) {
@@ -63,8 +63,8 @@ public static int readInt(byte[] buf, int i) {
}
public static long readLongLE(byte[] buf, int i) {
- return (buf[i] & 0xFFL) | ((buf[i+1] & 0xFFL) << 8) | ((buf[i+2] & 0xFFL) << 16) | ((buf[i+3] & 0xFFL) << 24)
- | ((buf[i+4] & 0xFFL) << 32) | ((buf[i+5] & 0xFFL) << 40) | ((buf[i+6] & 0xFFL) << 48) | ((buf[i+7] & 0xFFL) << 56);
+ return (buf[i] & 0xFFL) | ((buf[i + 1] & 0xFFL) << 8) | ((buf[i + 2] & 0xFFL) << 16) | ((buf[i + 3] & 0xFFL) << 24)
+ | ((buf[i + 4] & 0xFFL) << 32) | ((buf[i + 5] & 0xFFL) << 40) | ((buf[i + 6] & 0xFFL) << 48) | ((buf[i + 7] & 0xFFL) << 56);
}
public static void writeShortLE(byte[] buf, int off, int v) {
@@ -89,7 +89,7 @@ public static void writeShort(short[] buf, int off, int v) {
}
public static int readShortLE(byte[] buf, int i) {
- return (buf[i] & 0xFF) | ((buf[i+1] & 0xFF) << 8);
+ return (buf[i] & 0xFF) | ((buf[i + 1] & 0xFF) << 8);
}
public static int readShort(short[] buf, int off) {
diff --git a/src/java/net/jpountz/util/Utils.java b/src/java/net/jpountz/util/Utils.java
index bcb9f796..6f805f23 100644
--- a/src/java/net/jpountz/util/Utils.java
+++ b/src/java/net/jpountz/util/Utils.java
@@ -28,8 +28,8 @@ public enum Utils {
static {
String arch = System.getProperty("os.arch");
unalignedAccessAllowed = arch.equals("i386") || arch.equals("x86")
- || arch.equals("amd64") || arch.equals("x86_64")
- || arch.equals("aarch64") || arch.equals("ppc64le");
+ || arch.equals("amd64") || arch.equals("x86_64")
+ || arch.equals("aarch64") || arch.equals("ppc64le");
}
public static boolean isUnalignedAccessAllowed() {
diff --git a/src/java/net/jpountz/xxhash/XXHash32.java b/src/java/net/jpountz/xxhash/XXHash32.java
index 442e38ca..6d4254d6 100644
--- a/src/java/net/jpountz/xxhash/XXHash32.java
+++ b/src/java/net/jpountz/xxhash/XXHash32.java
@@ -40,7 +40,7 @@ public abstract class XXHash32 {
/**
* Computes the hash of the given slice of the {@link ByteBuffer}.
* {@link ByteBuffer#position() position} and {@link ByteBuffer#limit() limit}
- * are not modified.
+ * are not modified.
*
* @param buf the input data
* @param off the start offset in buf
diff --git a/src/java/net/jpountz/xxhash/XXHash64.java b/src/java/net/jpountz/xxhash/XXHash64.java
index 32572072..75141e52 100644
--- a/src/java/net/jpountz/xxhash/XXHash64.java
+++ b/src/java/net/jpountz/xxhash/XXHash64.java
@@ -40,7 +40,7 @@ public abstract class XXHash64 {
/**
* Computes the hash of the given slice of the {@link ByteBuffer}.
* {@link ByteBuffer#position() position} and {@link ByteBuffer#limit() limit}
- * are not modified.
+ * are not modified.
*
* @param buf the input data
* @param off the start offset in buf
diff --git a/src/java/net/jpountz/xxhash/XXHashFactory.java b/src/java/net/jpountz/xxhash/XXHashFactory.java
index e7a3e9ca..6724eb5b 100644
--- a/src/java/net/jpountz/xxhash/XXHashFactory.java
+++ b/src/java/net/jpountz/xxhash/XXHashFactory.java
@@ -58,7 +58,7 @@ private static XXHashFactory instance(String impl) {
/**
* Returns a {@link XXHashFactory} that returns {@link XXHash32} instances that
- * are native bindings to the original C API.
+ * are native bindings to the original C API.
*
*
*
* @return a {@link XXHashFactory} that returns {@link XXHash32} instances that
- * are native bindings to the original C API.
+ * are native bindings to the original C API.
*/
public static synchronized XXHashFactory nativeInstance() {
if (NATIVE_INSTANCE == null) {
@@ -86,10 +86,10 @@ public static synchronized XXHashFactory nativeInstance() {
/**
* Returns a {@link XXHashFactory} that returns {@link XXHash32} instances that
- * are written with Java's official API.
+ * are written with Java's official API.
*
* @return a {@link XXHashFactory} that returns {@link XXHash32} instances that
- * are written with Java's official API.
+ * are written with Java's official API.
*/
public static synchronized XXHashFactory safeInstance() {
if (JAVA_SAFE_INSTANCE == null) {
@@ -100,10 +100,10 @@ public static synchronized XXHashFactory safeInstance() {
/**
* Returns a {@link XXHashFactory} that returns {@link XXHash32} instances that
- * may use {@link sun.misc.Unsafe} to speed up hashing.
+ * 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.
+ * may use {@link sun.misc.Unsafe} to speed up hashing.
*/
public static synchronized XXHashFactory unsafeInstance() {
if (JAVA_UNSAFE_INSTANCE == null) {
diff --git a/src/test/net/jpountz/lz4/AbstractLZ4Test.java b/src/test/net/jpountz/lz4/AbstractLZ4Test.java
index e21e3c1a..66c82cba 100644
--- a/src/test/net/jpountz/lz4/AbstractLZ4Test.java
+++ b/src/test/net/jpountz/lz4/AbstractLZ4Test.java
@@ -54,7 +54,7 @@ public byte[] copyOf(byte[] data, int off, int len) {
@Override
public int maxCompressedLength(int len) {
- return LZ4Utils.maxCompressedLength(len);
+ return LZ4Utils.maxCompressedLength(len);
}
@Override
@@ -104,7 +104,7 @@ public byte[] copyOf(ByteBuffer data, int off, int len) {
@Override
public int maxCompressedLength(int len) {
- return LZ4Utils.maxCompressedLength(len);
+ return LZ4Utils.maxCompressedLength(len);
}
@Override
@@ -142,6 +142,7 @@ public int decompress(LZ4SafeDecompressor decompressor,
return decompressor.decompress(src, srcOff, srcLen, dest, destOff, maxDestLen);
}
}
+
public static final Tester