Skip to content

Commit

Permalink
Suppress illegal reflective access in shared cache (#70355)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasontedor authored and rjernst committed Mar 15, 2021
1 parent e464ec7 commit b901073
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ static List<String> systemJvmOptions() {
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",

javaLocaleProviders()
javaLocaleProviders(),
maybeAddOpensJavaIoToAllUnnamed()
)
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
}
Expand Down Expand Up @@ -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 "";
}

}

}

0 comments on commit b901073

Please sign in to comment.