Debug.java revision 2362
869N/A/*
869N/A * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
869N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
869N/A *
869N/A * This code is free software; you can redistribute it and/or modify it
869N/A * under the terms of the GNU General Public License version 2 only, as
869N/A * published by the Free Software Foundation.
869N/A *
869N/A * This code is distributed in the hope that it will be useful, but WITHOUT
869N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
869N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
869N/A * version 2 for more details (a copy is included in the LICENSE file that
869N/A * accompanied this code).
869N/A *
869N/A * You should have received a copy of the GNU General Public License version
869N/A * 2 along with this work; if not, write to the Free Software Foundation,
869N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
873N/A *
869N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
869N/A * or visit www.oracle.com if you need additional information or have any
869N/A * questions.
869N/A */
5005N/A
6045N/A/*
5934N/A * @test
869N/A * @bug 4350951
869N/A * @summary UnresolvedPermission assumes permission constructor
0N/A * with 2 string parameters
0N/A *
0N/A * @compile Debug.java DebugPermissionBad.java DebugPermission0.java DebugPermission1.java DebugPermission2.java
0N/A * @run main/othervm/policy=Debug.policy -Djava.security.debug=policy,access Debug
869N/A */
0N/A
0N/Apublic class Debug {
0N/A
869N/A public static void main(String[] args) {
0N/A
869N/A SecurityManager sm = System.getSecurityManager();
0N/A if (sm == null) {
869N/A throw new SecurityException("Test Failed: no SecurityManager");
869N/A }
869N/A
2624N/A try {
869N/A sm.checkPermission(new DebugPermissionBad("hello", 1));
48N/A throw new SecurityException("Test 1 Failed: no SecurityException");
869N/A } catch (SecurityException se) {
0N/A // good
869N/A }
716N/A
869N/A try {
1958N/A sm.checkPermission(new DebugPermission0());
1963N/A } catch (SecurityException se) {
2340N/A throw new SecurityException("Test 2 Failed");
3103N/A }
3127N/A
3679N/A try {
5244N/A sm.checkPermission(new DebugPermission1("1"));
1954N/A } catch (SecurityException se) {
1954N/A throw new SecurityException("Test 3 Failed");
1954N/A }
1954N/A
1954N/A try {
1954N/A sm.checkPermission(new DebugPermission2("1", "2"));
4306N/A } catch (SecurityException se) {
4306N/A throw new SecurityException("Test 4 Failed");
4306N/A }
1954N/A
1954N/A System.out.println("Test Succeeded");
1954N/A }
1954N/A}
5221N/A