diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index bbbb1e07f70..c64e8f6a716 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -22,10 +22,10 @@ name: "CodeQL"
on:
push:
- branches: ["4.1", "4.2", main]
+ branches: ["4.1", "4.2"]
pull_request:
# The branches below must be a subset of the branches above
- branches: ["4.1", "4.2", main]
+ branches: ["4.1", "4.2"]
schedule:
- cron: '0 13 * * 3'
@@ -89,6 +89,10 @@ jobs:
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
+ - uses: actions/setup-java@v4
+ with:
+ distribution: 'zulu'
+ java-version: '8' # The JDK version to make available on the path.
- name: Compile project
run: ./mvnw -B -ntp clean package -DskipTests=true
diff --git a/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java b/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
index 3a4f951d3ef..c4c21cad986 100644
--- a/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
+++ b/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
@@ -22,7 +22,6 @@
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectUtil;
import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SuppressJava6Requirement;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.UnstableApi;
@@ -42,8 +41,6 @@
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.locks.StampedLock;
-import static io.netty.util.internal.PlatformDependent.javaVersion;
-
/**
* An auto-tuning pooling allocator, that follows an anti-generational hypothesis.
*
@@ -70,7 +67,6 @@
* magazine, to be shared with other magazines.
* The {@link #createSharedChunkQueue()} method can be overridden to customize this queue.
*/
-@SuppressJava6Requirement(reason = "Guarded by version check")
@UnstableApi
final class AdaptivePoolingAllocator {
private static final int RETIRE_CAPACITY = 4 * 1024;
@@ -104,10 +100,6 @@ final class AdaptivePoolingAllocator {
AdaptivePoolingAllocator(ChunkAllocator chunkAllocator) {
this.chunkAllocator = chunkAllocator;
- if (javaVersion() < 8) {
- // The implementation uses StampedLock, which was introduced in Java 8.
- throw new IllegalStateException("This allocator require Java 8 or newer.");
- }
centralQueue = ObjectUtil.checkNotNull(createSharedChunkQueue(), "centralQueue");
magazineExpandLock = new StampedLock();
Magazine[] mags = new Magazine[4];
@@ -234,7 +226,6 @@ private boolean offerToQueue(ChunkByteBuf buffer) {
return centralQueue.offer(buffer);
}
- @SuppressJava6Requirement(reason = "Guarded by version check")
@SuppressWarnings("checkstyle:finalclass") // Checkstyle mistakenly believes this class should be final.
private static class AllocationStatistics extends StampedLock {
private static final long serialVersionUID = -8319929980932269688L;
diff --git a/buffer/src/main/java/io/netty/buffer/PooledUnsafeHeapByteBuf.java b/buffer/src/main/java/io/netty/buffer/PooledUnsafeHeapByteBuf.java
index 9a8674e12e3..ccc72c9031b 100644
--- a/buffer/src/main/java/io/netty/buffer/PooledUnsafeHeapByteBuf.java
+++ b/buffer/src/main/java/io/netty/buffer/PooledUnsafeHeapByteBuf.java
@@ -132,26 +132,18 @@ protected void _setLongLE(int index, long value) {
@Override
public ByteBuf setZero(int index, int length) {
- if (PlatformDependent.javaVersion() >= 7) {
- checkIndex(index, length);
- // Only do on java7+ as the needed Unsafe call was only added there.
- UnsafeByteBufUtil.setZero(memory, idx(index), length);
- return this;
- }
- return super.setZero(index, length);
+ checkIndex(index, length);
+ UnsafeByteBufUtil.setZero(memory, idx(index), length);
+ return this;
}
@Override
public ByteBuf writeZero(int length) {
- if (PlatformDependent.javaVersion() >= 7) {
- // Only do on java7+ as the needed Unsafe call was only added there.
- ensureWritable(length);
- int wIndex = writerIndex;
- UnsafeByteBufUtil.setZero(memory, idx(wIndex), length);
- writerIndex = wIndex + length;
- return this;
- }
- return super.writeZero(length);
+ ensureWritable(length);
+ int wIndex = writerIndex;
+ UnsafeByteBufUtil.setZero(memory, idx(wIndex), length);
+ writerIndex = wIndex + length;
+ return this;
}
@Override
diff --git a/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeHeapByteBuf.java b/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeHeapByteBuf.java
index 2644df4be1a..283e76fe6cb 100644
--- a/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeHeapByteBuf.java
+++ b/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeHeapByteBuf.java
@@ -248,26 +248,18 @@ protected void _setLongLE(int index, long value) {
@Override
public ByteBuf setZero(int index, int length) {
- if (PlatformDependent.javaVersion() >= 7) {
- // Only do on java7+ as the needed Unsafe call was only added there.
- checkIndex(index, length);
- UnsafeByteBufUtil.setZero(array, index, length);
- return this;
- }
- return super.setZero(index, length);
+ checkIndex(index, length);
+ UnsafeByteBufUtil.setZero(array, index, length);
+ return this;
}
@Override
public ByteBuf writeZero(int length) {
- if (PlatformDependent.javaVersion() >= 7) {
- // Only do on java7+ as the needed Unsafe call was only added there.
- ensureWritable(length);
- int wIndex = writerIndex;
- UnsafeByteBufUtil.setZero(array, wIndex, length);
- writerIndex = wIndex + length;
- return this;
- }
- return super.writeZero(length);
+ ensureWritable(length);
+ int wIndex = writerIndex;
+ UnsafeByteBufUtil.setZero(array, wIndex, length);
+ writerIndex = wIndex + length;
+ return this;
}
@Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java
index f35efaadba3..0a26f28d93e 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java
@@ -15,16 +15,12 @@
*/
package io.netty.handler.codec.http.websocketx;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.handler.codec.base64.Base64;
-import io.netty.util.CharsetUtil;
import io.netty.util.concurrent.FastThreadLocal;
import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SuppressJava6Requirement;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
/**
* A utility class mainly for use by web sockets
@@ -95,24 +91,8 @@ private static byte[] digest(FastThreadLocal digestFastThreadLoca
* @param data The data to encode
* @return An encoded string containing the data
*/
- @SuppressJava6Requirement(reason = "Guarded with java version check")
static String base64(byte[] data) {
- if (PlatformDependent.javaVersion() >= 8) {
- return java.util.Base64.getEncoder().encodeToString(data);
- }
- String encodedString;
- ByteBuf encodedData = Unpooled.wrappedBuffer(data);
- try {
- ByteBuf encoded = Base64.encode(encodedData);
- try {
- encodedString = encoded.toString(CharsetUtil.UTF_8);
- } finally {
- encoded.release();
- }
- } finally {
- encodedData.release();
- }
- return encodedString;
+ return Base64.getEncoder().encodeToString(data);
}
/**
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockEncoder.java
index 69217ca0508..c122e3c7f45 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockEncoder.java
@@ -17,7 +17,6 @@
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
-import io.netty.util.internal.PlatformDependent;
/**
* Super-class for SPDY header-block encoders.
@@ -30,14 +29,7 @@ public abstract class SpdyHeaderBlockEncoder {
static SpdyHeaderBlockEncoder newInstance(
SpdyVersion version, int compressionLevel, int windowBits, int memLevel) {
-
- if (PlatformDependent.javaVersion() >= 7) {
- return new SpdyHeaderBlockZlibEncoder(
- version, compressionLevel);
- } else {
- return new SpdyHeaderBlockJZlibEncoder(
- version, compressionLevel, windowBits, memLevel);
- }
+ return new SpdyHeaderBlockZlibEncoder(version, compressionLevel);
}
abstract ByteBuf encode(ByteBufAllocator alloc, SpdyHeadersFrame frame) throws Exception;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibEncoder.java
index 21a18f90a11..bf33d94ce23 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibEncoder.java
@@ -18,12 +18,10 @@
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
-import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SuppressJava6Requirement;
import java.util.zip.Deflater;
-import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
+import static io.netty.handler.codec.spdy.SpdyCodecUtil.SPDY_DICT;
import static io.netty.util.internal.ObjectUtil.checkNotNullWithIAE;
class SpdyHeaderBlockZlibEncoder extends SpdyHeaderBlockRawEncoder {
@@ -73,17 +71,11 @@ private ByteBuf encode(ByteBufAllocator alloc, int len) {
}
}
- @SuppressJava6Requirement(reason = "Guarded by java version check")
private boolean compressInto(ByteBuf compressed) {
byte[] out = compressed.array();
int off = compressed.arrayOffset() + compressed.writerIndex();
int toWrite = compressed.writableBytes();
- final int numBytes;
- if (PlatformDependent.javaVersion() >= 7) {
- numBytes = compressor.deflate(out, off, toWrite, Deflater.SYNC_FLUSH);
- } else {
- numBytes = compressor.deflate(out, off, toWrite);
- }
+ final int numBytes = compressor.deflate(out, off, toWrite, Deflater.SYNC_FLUSH);
compressed.writerIndex(compressed.writerIndex() + numBytes);
return numBytes == toWrite;
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyProtocolException.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyProtocolException.java
index e097d5cf714..99c3956cdd0 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyProtocolException.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyProtocolException.java
@@ -15,8 +15,6 @@
*/
package io.netty.handler.codec.spdy;
-import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SuppressJava6Requirement;
import io.netty.util.internal.ThrowableUtil;
public class SpdyProtocolException extends Exception {
@@ -50,17 +48,10 @@ public SpdyProtocolException(Throwable cause) {
}
static SpdyProtocolException newStatic(String message, Class> clazz, String method) {
- final SpdyProtocolException exception;
- if (PlatformDependent.javaVersion() >= 7) {
- exception = new StacklessSpdyProtocolException(message, true);
- } else {
- exception = new StacklessSpdyProtocolException(message);
- }
+ final SpdyProtocolException exception = new StacklessSpdyProtocolException(message, true);
return ThrowableUtil.unknownStackTrace(exception, clazz, method);
}
- @SuppressJava6Requirement(reason = "uses Java 7+ Exception.(String, Throwable, boolean, boolean)" +
- " but is guarded by version checks")
private SpdyProtocolException(String message, boolean shared) {
super(message, null, false, true);
assert shared;
@@ -69,10 +60,6 @@ private SpdyProtocolException(String message, boolean shared) {
private static final class StacklessSpdyProtocolException extends SpdyProtocolException {
private static final long serialVersionUID = -6302754207557485099L;
- StacklessSpdyProtocolException(String message) {
- super(message);
- }
-
StacklessSpdyProtocolException(String message, boolean shared) {
super(message, shared);
}
diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java
index 9b3e61fb9c5..d8787f3893a 100644
--- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java
+++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java
@@ -15,8 +15,6 @@
package io.netty.handler.codec.http2;
-import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SuppressJava6Requirement;
import io.netty.util.internal.ThrowableUtil;
import io.netty.util.internal.UnstableApi;
@@ -68,17 +66,10 @@ public Http2Exception(Http2Error error, String message, Throwable cause, Shutdow
static Http2Exception newStatic(Http2Error error, String message, ShutdownHint shutdownHint,
Class> clazz, String method) {
- final Http2Exception exception;
- if (PlatformDependent.javaVersion() >= 7) {
- exception = new StacklessHttp2Exception(error, message, shutdownHint, true);
- } else {
- exception = new StacklessHttp2Exception(error, message, shutdownHint);
- }
+ final Http2Exception exception = new StacklessHttp2Exception(error, message, shutdownHint, true);
return ThrowableUtil.unknownStackTrace(exception, clazz, method);
}
- @SuppressJava6Requirement(reason = "uses Java 7+ Exception.(String, Throwable, boolean, boolean)" +
- " but is guarded by version checks")
private Http2Exception(Http2Error error, String message, ShutdownHint shutdownHint, boolean shared) {
super(message, null, false, true);
assert shared;
diff --git a/codec/src/main/java/io/netty/handler/codec/compression/ByteBufChecksum.java b/codec/src/main/java/io/netty/handler/codec/compression/ByteBufChecksum.java
index 21c6f16a4ed..f8161b06b01 100644
--- a/codec/src/main/java/io/netty/handler/codec/compression/ByteBufChecksum.java
+++ b/codec/src/main/java/io/netty/handler/codec/compression/ByteBufChecksum.java
@@ -18,9 +18,7 @@
import io.netty.buffer.ByteBuf;
import io.netty.util.ByteProcessor;
import io.netty.util.internal.ObjectUtil;
-import io.netty.util.internal.PlatformDependent;
-import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
@@ -28,27 +26,11 @@
/**
* {@link Checksum} implementation which can directly act on a {@link ByteBuf}.
- *
+ *
* Implementations may optimize access patterns depending on if the {@link ByteBuf} is backed by a
* byte array ({@link ByteBuf#hasArray()} is {@code true}) or not.
*/
abstract class ByteBufChecksum implements Checksum {
-
- /**
- * on OpenJDK Adler32 and CRC32 both calls ZipUtils.loadLibrary on class init.
- */
- private static class ZlibChecksumMethods {
- private static final Method ADLER32_UPDATE_METHOD;
- private static final Method CRC32_UPDATE_METHOD;
-
- static {
- // See if we can use fast-path when using ByteBuf that is not heap based as Adler32 and CRC32 added support
- // for update(ByteBuffer) in JDK8.
- ADLER32_UPDATE_METHOD = updateByteBuffer(new Adler32());
- CRC32_UPDATE_METHOD = updateByteBuffer(new CRC32());
- }
- }
-
private final ByteProcessor updateProcessor = new ByteProcessor() {
@Override
public boolean process(byte value) throws Exception {
@@ -57,31 +39,12 @@ public boolean process(byte value) throws Exception {
}
};
- private static Method updateByteBuffer(Checksum checksum) {
- if (PlatformDependent.javaVersion() >= 8) {
- try {
- Method method = checksum.getClass().getDeclaredMethod("update", ByteBuffer.class);
- method.invoke(checksum, ByteBuffer.allocate(1));
- return method;
- } catch (Throwable ignore) {
- return null;
- }
- }
- return null;
- }
-
static ByteBufChecksum wrapChecksum(Checksum checksum) {
ObjectUtil.checkNotNull(checksum, "checksum");
if (checksum instanceof ByteBufChecksum) {
return (ByteBufChecksum) checksum;
}
- if (checksum instanceof Adler32 && ZlibChecksumMethods.ADLER32_UPDATE_METHOD != null) {
- return new ReflectiveByteBufChecksum(checksum, ZlibChecksumMethods.ADLER32_UPDATE_METHOD);
- }
- if (checksum instanceof CRC32 && ZlibChecksumMethods.CRC32_UPDATE_METHOD != null) {
- return new ReflectiveByteBufChecksum(checksum, ZlibChecksumMethods.CRC32_UPDATE_METHOD);
- }
- return new SlowByteBufChecksum(checksum);
+ return new JdkByteBufChecksum(checksum);
}
/**
@@ -95,40 +58,32 @@ public void update(ByteBuf b, int off, int len) {
}
}
- private static final class ReflectiveByteBufChecksum extends SlowByteBufChecksum {
- private final Method method;
+ private static class JdkByteBufChecksum extends ByteBufChecksum {
+ protected final Checksum checksum;
- ReflectiveByteBufChecksum(Checksum checksum, Method method) {
- super(checksum);
- this.method = method;
+ JdkByteBufChecksum(Checksum checksum) {
+ this.checksum = checksum;
+ }
+
+ @Override
+ public void update(int b) {
+ checksum.update(b);
}
@Override
public void update(ByteBuf b, int off, int len) {
if (b.hasArray()) {
update(b.array(), b.arrayOffset() + off, len);
+ } else if (checksum instanceof CRC32) {
+ ByteBuffer byteBuffer = CompressionUtil.safeNioBuffer(b, off, len);
+ ((CRC32) checksum).update(byteBuffer);
+ } else if (checksum instanceof Adler32) {
+ ByteBuffer byteBuffer = CompressionUtil.safeNioBuffer(b, off, len);
+ ((Adler32) checksum).update(byteBuffer);
} else {
- try {
- method.invoke(checksum, CompressionUtil.safeNioBuffer(b, off, len));
- } catch (Throwable cause) {
- throw new Error();
- }
+ super.update(b, off, len);
}
}
- }
-
- private static class SlowByteBufChecksum extends ByteBufChecksum {
-
- protected final Checksum checksum;
-
- SlowByteBufChecksum(Checksum checksum) {
- this.checksum = checksum;
- }
-
- @Override
- public void update(int b) {
- checksum.update(b);
- }
@Override
public void update(byte[] b, int off, int len) {
diff --git a/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java b/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
index e43f6d561e3..fb9e51fb4a2 100644
--- a/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
@@ -23,8 +23,6 @@
import io.netty.util.concurrent.PromiseNotifier;
import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.ObjectUtil;
-import io.netty.util.internal.PlatformDependent;
-import io.netty.util.internal.SuppressJava6Requirement;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -344,11 +342,7 @@ private ChannelFuture finishEncode(final ChannelHandlerContext ctx, ChannelPromi
return ctx.writeAndFlush(footer, promise);
}
- @SuppressJava6Requirement(reason = "Usage guarded by java version check")
private void deflate(ByteBuf out) {
- if (PlatformDependent.javaVersion() < 7) {
- deflateJdk6(out);
- }
int numBytes;
do {
int writerIndex = out.writerIndex();
@@ -358,16 +352,6 @@ private void deflate(ByteBuf out) {
} while (numBytes > 0);
}
- private void deflateJdk6(ByteBuf out) {
- int numBytes;
- do {
- int writerIndex = out.writerIndex();
- numBytes = deflater.deflate(
- out.array(), out.arrayOffset() + writerIndex, out.writableBytes());
- out.writerIndex(writerIndex + numBytes);
- } while (numBytes > 0);
- }
-
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
diff --git a/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java b/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java
index d41d329af5e..5f4e5c4ae84 100644
--- a/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java
+++ b/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java
@@ -15,7 +15,6 @@
*/
package io.netty.handler.codec.compression;
-import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
@@ -31,28 +30,24 @@ public final class ZlibCodecFactory {
private static final boolean noJdkZlibDecoder;
private static final boolean noJdkZlibEncoder;
- private static final boolean supportsWindowSizeAndMemLevel;
static {
- noJdkZlibDecoder = SystemPropertyUtil.getBoolean("io.netty.noJdkZlibDecoder",
- PlatformDependent.javaVersion() < 7);
+ noJdkZlibDecoder = SystemPropertyUtil.getBoolean("io.netty.noJdkZlibDecoder", false);
logger.debug("-Dio.netty.noJdkZlibDecoder: {}", noJdkZlibDecoder);
noJdkZlibEncoder = SystemPropertyUtil.getBoolean("io.netty.noJdkZlibEncoder", false);
logger.debug("-Dio.netty.noJdkZlibEncoder: {}", noJdkZlibEncoder);
-
- supportsWindowSizeAndMemLevel = noJdkZlibDecoder || PlatformDependent.javaVersion() >= 7;
}
/**
* Returns {@code true} if specify a custom window size and mem level is supported.
*/
public static boolean isSupportingWindowSizeAndMemLevel() {
- return supportsWindowSizeAndMemLevel;
+ return true;
}
public static ZlibEncoder newZlibEncoder(int compressionLevel) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder) {
+ if (noJdkZlibEncoder) {
return new JZlibEncoder(compressionLevel);
} else {
return new JdkZlibEncoder(compressionLevel);
@@ -60,7 +55,7 @@ public static ZlibEncoder newZlibEncoder(int compressionLevel) {
}
public static ZlibEncoder newZlibEncoder(ZlibWrapper wrapper) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder) {
+ if (noJdkZlibEncoder) {
return new JZlibEncoder(wrapper);
} else {
return new JdkZlibEncoder(wrapper);
@@ -68,7 +63,7 @@ public static ZlibEncoder newZlibEncoder(ZlibWrapper wrapper) {
}
public static ZlibEncoder newZlibEncoder(ZlibWrapper wrapper, int compressionLevel) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder) {
+ if (noJdkZlibEncoder) {
return new JZlibEncoder(wrapper, compressionLevel);
} else {
return new JdkZlibEncoder(wrapper, compressionLevel);
@@ -76,7 +71,7 @@ public static ZlibEncoder newZlibEncoder(ZlibWrapper wrapper, int compressionLev
}
public static ZlibEncoder newZlibEncoder(ZlibWrapper wrapper, int compressionLevel, int windowBits, int memLevel) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder ||
+ if (noJdkZlibEncoder ||
windowBits != DEFAULT_JDK_WINDOW_SIZE || memLevel != DEFAULT_JDK_MEM_LEVEL) {
return new JZlibEncoder(wrapper, compressionLevel, windowBits, memLevel);
} else {
@@ -85,7 +80,7 @@ public static ZlibEncoder newZlibEncoder(ZlibWrapper wrapper, int compressionLev
}
public static ZlibEncoder newZlibEncoder(byte[] dictionary) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder) {
+ if (noJdkZlibEncoder) {
return new JZlibEncoder(dictionary);
} else {
return new JdkZlibEncoder(dictionary);
@@ -93,7 +88,7 @@ public static ZlibEncoder newZlibEncoder(byte[] dictionary) {
}
public static ZlibEncoder newZlibEncoder(int compressionLevel, byte[] dictionary) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder) {
+ if (noJdkZlibEncoder) {
return new JZlibEncoder(compressionLevel, dictionary);
} else {
return new JdkZlibEncoder(compressionLevel, dictionary);
@@ -101,7 +96,7 @@ public static ZlibEncoder newZlibEncoder(int compressionLevel, byte[] dictionary
}
public static ZlibEncoder newZlibEncoder(int compressionLevel, int windowBits, int memLevel, byte[] dictionary) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibEncoder ||
+ if (noJdkZlibEncoder ||
windowBits != DEFAULT_JDK_WINDOW_SIZE || memLevel != DEFAULT_JDK_MEM_LEVEL) {
return new JZlibEncoder(compressionLevel, windowBits, memLevel, dictionary);
} else {
@@ -110,7 +105,7 @@ public static ZlibEncoder newZlibEncoder(int compressionLevel, int windowBits, i
}
public static ZlibDecoder newZlibDecoder() {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibDecoder) {
+ if (noJdkZlibDecoder) {
return new JZlibDecoder();
} else {
return new JdkZlibDecoder(true);
@@ -118,7 +113,7 @@ public static ZlibDecoder newZlibDecoder() {
}
public static ZlibDecoder newZlibDecoder(ZlibWrapper wrapper) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibDecoder) {
+ if (noJdkZlibDecoder) {
return new JZlibDecoder(wrapper);
} else {
return new JdkZlibDecoder(wrapper, true);
@@ -126,7 +121,7 @@ public static ZlibDecoder newZlibDecoder(ZlibWrapper wrapper) {
}
public static ZlibDecoder newZlibDecoder(byte[] dictionary) {
- if (PlatformDependent.javaVersion() < 7 || noJdkZlibDecoder) {
+ if (noJdkZlibDecoder) {
return new JZlibDecoder(dictionary);
} else {
return new JdkZlibDecoder(dictionary);
diff --git a/common/src/main/java/io/netty/util/NetUtil.java b/common/src/main/java/io/netty/util/NetUtil.java
index 63da7981a72..3941c3aa2b2 100644
--- a/common/src/main/java/io/netty/util/NetUtil.java
+++ b/common/src/main/java/io/netty/util/NetUtil.java
@@ -1073,13 +1073,12 @@ private static String toAddressString(byte[] bytes, int offset, boolean ipv4Mapp
}
/**
- * Returns {@link InetSocketAddress#getHostString()} if Java >= 7,
- * or {@link InetSocketAddress#getHostName()} otherwise.
+ * Returns {@link InetSocketAddress#getHostString()}.
* @param addr The address
* @return the host string
*/
public static String getHostname(InetSocketAddress addr) {
- return PlatformDependent.javaVersion() >= 7 ? addr.getHostString() : addr.getHostName();
+ return addr.getHostString();
}
/**
diff --git a/common/src/main/java/io/netty/util/internal/Hidden.java b/common/src/main/java/io/netty/util/internal/Hidden.java
index cf32e154ff5..746e91c8fa2 100644
--- a/common/src/main/java/io/netty/util/internal/Hidden.java
+++ b/common/src/main/java/io/netty/util/internal/Hidden.java
@@ -35,7 +35,6 @@ class Hidden {
* and SHOULD NOT be considered a public API.
*/
@UnstableApi
- @SuppressJava6Requirement(reason = "BlockHound is Java 8+, but this class is only loaded by it's SPI")
public static final class NettyBlockHoundIntegration implements BlockHoundIntegration {
@Override
@@ -171,7 +170,6 @@ public void applyTo(BlockHound.Builder builder) {
public Predicate apply(final Predicate p) {
return new Predicate() {
@Override
- @SuppressJava6Requirement(reason = "Predicate#test")
public boolean test(Thread thread) {
return p.test(thread) ||
thread instanceof FastThreadLocalThread &&
diff --git a/common/src/main/java/io/netty/util/internal/LongAdderCounter.java b/common/src/main/java/io/netty/util/internal/LongAdderCounter.java
index 7b4c2cecabc..8320b9eba84 100644
--- a/common/src/main/java/io/netty/util/internal/LongAdderCounter.java
+++ b/common/src/main/java/io/netty/util/internal/LongAdderCounter.java
@@ -17,7 +17,6 @@
import java.util.concurrent.atomic.LongAdder;
-@SuppressJava6Requirement(reason = "Usage guarded by java version check")
final class LongAdderCounter extends LongAdder implements LongCounter {
@Override
diff --git a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java
index 41f615f3fb8..2f48ba1ea6c 100644
--- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java
+++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java
@@ -29,6 +29,8 @@
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.attribute.PosixFilePermission;
import java.security.AccessController;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -399,7 +401,8 @@ private static void loadLibrary(final ClassLoader loader, final String name, fin
if (suppressed != null) {
ThrowableUtil.addSuppressed(nsme, suppressed);
}
- rethrowWithMoreDetailsIfPossible(name, nsme);
+ throw new LinkageError(
+ "Possible multiple incompatible native libraries on the classpath for '" + name + "'?", nsme);
} catch (UnsatisfiedLinkError ule) {
if (suppressed != null) {
ThrowableUtil.addSuppressed(ule, suppressed);
@@ -408,15 +411,6 @@ private static void loadLibrary(final ClassLoader loader, final String name, fin
}
}
- @SuppressJava6Requirement(reason = "Guarded by version check")
- private static void rethrowWithMoreDetailsIfPossible(String name, NoSuchMethodError error) {
- if (PlatformDependent.javaVersion() >= 7) {
- throw new LinkageError(
- "Possible multiple incompatible native libraries on the classpath for '" + name + "'?", error);
- }
- throw error;
- }
-
private static void loadLibraryByHelper(final Class> helper, final String name, final boolean absolute)
throws UnsatisfiedLinkError {
Object ret = AccessController.doPrivileged(new PrivilegedAction