Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.31 release] Correctly throw UOE from setSecurityManager #14453

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions jcl/src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,15 @@ public static void setSecurityManager(final SecurityManager s) {
@SuppressWarnings("removal")
final SecurityManager currentSecurity = security;

if ((currentSecurity == null) && (s == null)) {
/* Return if the input argument is null and no security manager has been established. */
return;
}

/*[IF JAVA_SPEC_VERSION > 11]*/
if (throwUOEFromSetSM) {
/* The security manager is not allowed to be set dynamically. Return if the
* argument is null. UnsupportedOperationException should only be thrown for
* a non-null argument.
*/
if (s == null) {
return;
}
/*[MSG "K0B00", "The Security Manager is deprecated and will be removed in a future release"]*/
throw new UnsupportedOperationException(com.ibm.oti.util.Msg.getString("K0B00")); //$NON-NLS-1$
}
Expand Down