From 3e0233bc7138d7cedecedbe43242db65fa6e56de Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Thu, 5 Sep 2024 20:51:08 +0400 Subject: [PATCH] 8301118: Ignore allow and disallow options for java.security.manager System Property --- .../share/classes/java/lang/System.java | 2 ++ .../lang/System/AllowSecurityManager.java | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/jdk/java/lang/System/AllowSecurityManager.java diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index 0f20f3e6abc..797996a9337 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -2062,6 +2062,8 @@ private static void initPhase3() { if (cn != null) { if (cn.isEmpty() || "default".equals(cn)) { System.setSecurityManager(new SecurityManager()); + } else if ("allow".equals(cn) || "disallow".equals(cn)) { + // ignore allow/disallow options } else { try { Class c = Class.forName(cn, false, ClassLoader.getBuiltinAppClassLoader()); diff --git a/test/jdk/java/lang/System/AllowSecurityManager.java b/test/jdk/java/lang/System/AllowSecurityManager.java new file mode 100644 index 00000000000..30f0c592957 --- /dev/null +++ b/test/jdk/java/lang/System/AllowSecurityManager.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024, Azul Systems, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8301118 + * @summary Ignore allow and disallow options for java.security.manager System Property + * @run main/othervm AllowSecurityManager + * @run main/othervm -Djava.security.manager=disallow AllowSecurityManager + * @run main/othervm -Djava.security.manager=allow AllowSecurityManager + */ + +public class AllowSecurityManager { + public static void main(String[] args) {} +}