diff --git a/extensions/kafka-client/runtime/src/main/java/io/smallrye/reactive/kafka/graal/KafkaSubstitutions.java b/extensions/kafka-client/runtime/src/main/java/io/smallrye/reactive/kafka/graal/KafkaSubstitutions.java index 852c6ca247a6e1..8325fdd9c472f4 100644 --- a/extensions/kafka-client/runtime/src/main/java/io/smallrye/reactive/kafka/graal/KafkaSubstitutions.java +++ b/extensions/kafka-client/runtime/src/main/java/io/smallrye/reactive/kafka/graal/KafkaSubstitutions.java @@ -1,10 +1,13 @@ package io.smallrye.reactive.kafka.graal; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; +import sun.misc.Unsafe; + @TargetClass(className = "org.apache.kafka.common.network.SaslChannelBuilder") final class Target_org_apache_kafka_common_network_SaslChannelBuilder { @@ -17,6 +20,20 @@ private static String defaultKerberosRealm() throws ClassNotFoundException, NoSu } +@TargetClass(className = "org.apache.kafka.shaded.com.google.protobuf.UnsafeUtil") +final class Target_org_apache_kafka_shaded_com_google_protobuf_UnsafeUtil { + @Substitute + static sun.misc.Unsafe getUnsafe() { + try { + Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafe.setAccessible(true); + return (Unsafe) theUnsafe.get(null); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} + class KafkaSubstitutions { }