New posts

This commit is contained in:
2026-11-06 21:43:48 +05:30
parent ecceaa8b32
commit f7b6c1efca
33 changed files with 1258 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.util.internal.PlatformDependent;
/** A real third-party library that uses Unsafe: allocate one direct Netty buffer and use it. Compile and run with netty-common + netty-buffer on the class path. */
public class NettyProbe {
public static void main(String[] args) {
System.out.println("netty sees Unsafe: " + PlatformDependent.hasUnsafe());
ByteBuf buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(16);
buf.writeLong(0xCAFEBABEL);
System.out.println("direct=" + buf.isDirect() + " hasMemoryAddress=" + buf.hasMemoryAddress() + " readLong=" + Long.toHexString(buf.readLong()));
buf.release();
System.out.println("done");
}
}