Skip to content

Commit 0a198b5

Browse files
committed
eagerly initialize OffHeapReflectionUtils
1 parent bffb289 commit 0a198b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.elasticsearch.entitlement.runtime.policy.entitlements.LoadNativeLibrariesEntitlement;
4141
import org.elasticsearch.env.Environment;
4242
import org.elasticsearch.index.IndexVersion;
43+
import org.elasticsearch.index.codec.vectors.reflect.OffHeapReflectionUtils;
4344
import org.elasticsearch.jdk.JarHell;
4445
import org.elasticsearch.jdk.RuntimeVersionFeature;
4546
import org.elasticsearch.monitor.jvm.HotThreads;
@@ -232,7 +233,9 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException {
232233
// RequestHandlerRegistry and MethodHandlers classes do nontrivial static initialization which should always succeed but load
233234
// it now (before SM) to be sure
234235
RequestHandlerRegistry.class,
235-
MethodHandlers.class
236+
MethodHandlers.class,
237+
// Ensure member access and reflection lookup are as expected
238+
OffHeapReflectionUtils.class
236239
);
237240

238241
// load the plugin Java modules and layers now for use in entitlements
@@ -394,7 +397,7 @@ private static void reflectiveStartProcess(ProcessBuilder pb) throws Exception {
394397
private static void ensureInitialized(Class<?>... classes) {
395398
for (final var clazz : classes) {
396399
try {
397-
MethodHandles.publicLookup().ensureInitialized(clazz);
400+
MethodHandles.lookup().ensureInitialized(clazz);
398401
} catch (IllegalAccessException unexpected) {
399402
throw new AssertionError(unexpected);
400403
}

0 commit comments

Comments
 (0)