Skip to content

Commit

Permalink
Register methods that are reflectively accessed by netty during init
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Nov 21, 2024
1 parent 296ffde commit 357b6e0
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,8 +83,21 @@ public SystemPropertyBuildItem setNettyMachineId() {
NativeImageConfigBuildItem build(
NettyBuildTimeConfig config,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
List<MinNettyAllocatorMaxOrderBuildItem> 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", "<init>", 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", "<init>", new String[] { long.class.getName(), int.class.getName() }));

reflectiveClass.produce(ReflectiveClassBuildItem.builder("io.netty.channel.socket.nio.NioSocketChannel")
.build());
reflectiveClass
Expand Down

0 comments on commit 357b6e0

Please sign in to comment.