diff --git a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java index 8ce4f9dc8f56a..c5469651ce15f 100644 --- a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java +++ b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java @@ -28,6 +28,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem; @@ -82,8 +83,21 @@ public SystemPropertyBuildItem setNettyMachineId() { NativeImageConfigBuildItem build( NettyBuildTimeConfig config, BuildProducer reflectiveClass, + BuildProducer reflectiveMethods, List minMaxOrderBuildItems) { + reflectiveMethods.produce( + new ReflectiveMethodBuildItem("Reflectively accessed through PlatformDependent0's static initializer", + "jdk.internal.misc.Unsafe", "getUnsafe", new String[0])); + // in JDK >= 21 the constructor has `long, long` signature + reflectiveMethods.produce( + new ReflectiveMethodBuildItem("Reflectively accessed through PlatformDependent0's static initializer", + "java.nio.DirectByteBuffer", "", new String[] { long.class.getName(), long.class.getName() })); + // in JDK < 21 the constructor has `long, int` signature + reflectiveMethods.produce( + new ReflectiveMethodBuildItem("Reflectively accessed through PlatformDependent0's static initializer", + "java.nio.DirectByteBuffer", "", new String[] { long.class.getName(), int.class.getName() })); + reflectiveClass.produce(ReflectiveClassBuildItem.builder("io.netty.channel.socket.nio.NioSocketChannel") .build()); reflectiveClass