From 12ccf6df7ee46478f702049cb2f1c5128ccb69ae Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Wed, 3 Apr 2024 09:52:32 +0300 Subject: [PATCH] Recompute array index shift for unsafe access in JCTools Fixes segmentation faults when using mutiny. --- extensions/mutiny/runtime/pom.xml | 5 +++++ .../quarkus/mutiny/runtime/JCToolsSupport.java | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/JCToolsSupport.java diff --git a/extensions/mutiny/runtime/pom.xml b/extensions/mutiny/runtime/pom.xml index 4d06ca741a0997..80521e1ff2ea6b 100644 --- a/extensions/mutiny/runtime/pom.xml +++ b/extensions/mutiny/runtime/pom.xml @@ -47,6 +47,11 @@ assertj-core test + + + org.graalvm.sdk + nativeimage + diff --git a/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/JCToolsSupport.java b/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/JCToolsSupport.java new file mode 100644 index 00000000000000..b93655bff1e18f --- /dev/null +++ b/extensions/mutiny/runtime/src/main/java/io/quarkus/mutiny/runtime/JCToolsSupport.java @@ -0,0 +1,17 @@ +package io.quarkus.mutiny.runtime; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.TargetClass; + +class JCToolsSupport { +} + +// Thanks to https://github.com/DataDog/dd-trace-java/pull/6020 +@TargetClass(className = "org.jctools.util.UnsafeRefArrayAccess") +final class Target_org_jctools_util_UnsafeRefArrayAccess { + + @Alias + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.ArrayIndexShift, declClass = Object[].class) + public static int REF_ELEMENT_SHIFT; +} \ No newline at end of file