sounds good. Thanks for the PR. Looks good. b109, should we be checking build too? @johnou honestly I think we either should either just assume its ok if people use java8 (and if its not they should really upgrade) or only not use it for java9 and higher. /cc @hc-codersatlas WDYT ? @normanmaurer agree
Not a part of this commit, but is this commented out code necessary? Same above. Optional: consider splitting the manual safepointer to make the inliner happy.
Only apply copyMemoy safepoint for java <= 8
Hi, as per https://bugs.openjdk.java.net/browse/JDK-8149596 (and the source code of Java.nio.Bits) safepoint polling is no longer required (or rather it shouldn't be done). It's included as part of Unsafe.copyMemory.

Can we add a check to PlatformDependent where this occurs for java version <= 8 so we don't essentially do safepoint polling twice?

Thanks.
common/src/main/java/io/netty/util/internal/PlatformDependent0.java
common/src/main/java/io/netty/util/internal/PlatformDependent0.java
diff --git a/common/src/main/java/io/netty/util/internal/PlatformDependent0.java b/common/src/main/java/io/netty/util/internal/PlatformDependent0.java
index c6ebb55131d..53e9ed7bdcf 100644
--- a/common/src/main/java/io/netty/util/internal/PlatformDependent0.java
+++ b/common/src/main/java/io/netty/util/internal/PlatformDependent0.java
@@ -550,7 +550,16 @@ static void putLong(byte[] data, int index, long value) {
     }
 
     static void copyMemory(long srcAddr, long dstAddr, long length) {
-        //UNSAFE.copyMemory(srcAddr, dstAddr, length);
+        // Manual safe-point polling is only needed prior Java9:
+        // See https://bugs.openjdk.java.net/browse/JDK-8149596
+        if (javaVersion() <= 8) {
+            copyMemoryWithSafePointPolling(srcAddr, dstAddr, length);
+        } else {
+            UNSAFE.copyMemory(srcAddr, dstAddr, length);
+        }
+    }
+
+    private static void copyMemoryWithSafePointPolling(long srcAddr, long dstAddr, long length) {
         while (length > 0) {
             long size = Math.min(length, UNSAFE_COPY_THRESHOLD);
             UNSAFE.copyMemory(srcAddr, dstAddr, size);
@@ -561,7 +570,17 @@ static void copyMemory(long srcAddr, long dstAddr, long length) {
     }
 
     static void copyMemory(Object src, long srcOffset, Object dst, long dstOffset, long length) {
-        //UNSAFE.copyMemory(src, srcOffset, dst, dstOffset, length);
+        // Manual safe-point polling is only needed prior Java9:
+        // See https://bugs.openjdk.java.net/browse/JDK-8149596
+        if (javaVersion() <= 8) {
+            copyMemoryWithSafePointPolling(src, srcOffset, dst, dstOffset, length);
+        } else {
+            UNSAFE.copyMemory(src, srcOffset, dst, dstOffset, length);
+        }
+    }
+
+    private static void copyMemoryWithSafePointPolling(
+            Object src, long srcOffset, Object dst, long dstOffset, long length) {
         while (length > 0) {
             long size = Math.min(length, UNSAFE_COPY_THRESHOLD);
             UNSAFE.copyMemory(src, srcOffset, dst, dstOffset, size);
