Skip to content

Commit

Permalink
Merge pull request #44618 from zakkak/2024-11-21-register-methods-acc…
Browse files Browse the repository at this point in the history
…essed-reflectively-from-netty

Register methods that are reflectively accessed by netty during init
  • Loading branch information
cescoffier authored Nov 24, 2024
2 parents cb7acc9 + 357b6e0 commit 3280e47
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 3280e47

Please sign in to comment.