Skip to content

Commit

Permalink
Check for JDK version while setting java.security.manager option (#5205)
Browse files Browse the repository at this point in the history
Signed-off-by: Rabi Panda <[email protected]>
  • Loading branch information
adnapibar authored Nov 10, 2022
1 parent f0925f7 commit 4fc5c8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ public void execute(Task t) {
test.systemProperty("java.locale.providers", "SPI,JRE");
} else {
test.systemProperty("java.locale.providers", "SPI,COMPAT");
test.jvmArgs("--illegal-access=warn", "-Djava.security.manager=allow");
test.jvmArgs("--illegal-access=warn");
}
if (test.getJavaVersion().compareTo(JavaVersion.VERSION_17) > 0) {
test.jvmArgs("-Djava.security.manager=allow");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ static List<String> systemJvmOptions() {
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
// security manager
"-Djava.security.manager=allow",
allowSecurityManagerOption(),
javaLocaleProviders()
)
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
}

private static String allowSecurityManagerOption() {
if (Runtime.version().feature() > 17) {
return "-Djava.security.manager=allow";
} else {
return "";
}
}

private static String maybeShowCodeDetailsInExceptionMessages() {
if (Runtime.version().feature() >= 14) {
return "-XX:+ShowCodeDetailsInExceptionMessages";
Expand Down

0 comments on commit 4fc5c8d

Please sign in to comment.