Skip to content

Commit d9e4586

Browse files
authored
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.
1 parent a68f781 commit d9e4586

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/SystemJvmOptions.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static List<String> systemJvmOptions() {
5656
"-Dlog4j.shutdownHookEnabled=false",
5757
"-Dlog4j2.disable.jmx=true",
5858

59-
javaLocaleProviders()
59+
javaLocaleProviders(),
60+
maybeAddOpensJavaIoToAllUnnamed()
6061
)
6162
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
6263
}
@@ -87,4 +88,19 @@ private static String javaLocaleProviders() {
8788
}
8889
}
8990

91+
private static String maybeAddOpensJavaIoToAllUnnamed() {
92+
/*
93+
* Temporarily suppress illegal reflective access in searchable snapshots shared cache preallocation; this is temporary while we
94+
* explore alternatives. See org.elasticsearch.xpack.searchablesnapshots.preallocate.Preallocate.
95+
*
96+
* TODO: either modularlize Elasticsearch so that we can limit the opening of this module, or find an alternative
97+
*/
98+
if (JavaVersion.majorVersion(JavaVersion.CURRENT) >= 9) {
99+
return "--add-opens=java.base/java.io=ALL-UNNAMED";
100+
} else {
101+
return "";
102+
}
103+
104+
}
105+
90106
}

0 commit comments

Comments
 (0)