From d9e45861358ebb3341d4bc03fec013199c3f19f9 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 15 Mar 2021 19:15:41 -0400 Subject: [PATCH] Suppress illegal reflective access in shared cache (#70355) This commit temporarily supressess an illegal reflective access warning by opening the java.io module to all unnamed modules. This is needed when using the searchable snapshots shared cache due to some reflective access that occurs there. This is temporary while we explore alternatives. --- .../tools/launchers/SystemJvmOptions.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java index 051d0ad0d7780..998a307781c25 100644 --- a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java +++ b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java @@ -56,7 +56,8 @@ static List systemJvmOptions() { "-Dlog4j.shutdownHookEnabled=false", "-Dlog4j2.disable.jmx=true", - javaLocaleProviders() + javaLocaleProviders(), + maybeAddOpensJavaIoToAllUnnamed() ) ).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList()); } @@ -87,4 +88,19 @@ private static String javaLocaleProviders() { } } + private static String maybeAddOpensJavaIoToAllUnnamed() { + /* + * Temporarily suppress illegal reflective access in searchable snapshots shared cache preallocation; this is temporary while we + * explore alternatives. See org.elasticsearch.xpack.searchablesnapshots.preallocate.Preallocate. + * + * TODO: either modularlize Elasticsearch so that we can limit the opening of this module, or find an alternative + */ + if (JavaVersion.majorVersion(JavaVersion.CURRENT) >= 9) { + return "--add-opens=java.base/java.io=ALL-UNNAMED"; + } else { + return ""; + } + + } + }