Skip to content

Commit

Permalink
[7.17] Allow to set the security manager (#82053)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHegarty committed Jan 7, 2022
1 parent 7e4f632 commit 2cd9cca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public void execute(Task t) {
"--add-opens=java.management/java.lang.management=ALL-UNNAMED"
);
}
if (BuildParams.getRuntimeJavaVersion().isCompatibleWith(JavaVersion.VERSION_18)) {
test.jvmArgs("-Djava.security.manager=allow");
}
}
});
test.getJvmArgumentProviders().add(nonInputProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ static List<String> systemJvmOptions() {
"-Dlog4j2.formatMsgNoLookups=true",

javaLocaleProviders(),
maybeAddOpensJavaIoToAllUnnamed()
maybeAddOpensJavaIoToAllUnnamed(),
maybeAllowSecurityManager()
)
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
}
Expand All @@ -71,6 +72,15 @@ private static String maybeShowCodeDetailsInExceptionMessages() {
}
}

// The security manager needs to be explicitly allowed on JDK 18+.
private static String maybeAllowSecurityManager() {
if (JavaVersion.majorVersion(JavaVersion.CURRENT) >= 18) {
return "-Djava.security.manager=allow";
} else {
return "";
}
}

private static String javaLocaleProviders() {
/**
* SPI setting is used to allow loading custom CalendarDataProvider
Expand Down

0 comments on commit 2cd9cca

Please sign in to comment.