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 ""; + } + + } + }