Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/security/UnresolvedPermission/Debug.java
41149 views
1
/*
2
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 4350951
27
* @summary UnresolvedPermission assumes permission constructor
28
* with 2 string parameters
29
*
30
* @compile Debug.java DebugPermissionBad.java DebugPermission0.java DebugPermission1.java DebugPermission2.java
31
* @run main/othervm/policy=Debug.policy -Djava.security.debug=policy,access Debug
32
*/
33
34
public class Debug {
35
36
public static void main(String[] args) {
37
38
SecurityManager sm = System.getSecurityManager();
39
if (sm == null) {
40
throw new SecurityException("Test Failed: no SecurityManager");
41
}
42
43
try {
44
sm.checkPermission(new DebugPermissionBad("hello", 1));
45
throw new SecurityException("Test 1 Failed: no SecurityException");
46
} catch (SecurityException se) {
47
// good
48
}
49
50
try {
51
sm.checkPermission(new DebugPermission0());
52
} catch (SecurityException se) {
53
throw new SecurityException("Test 2 Failed");
54
}
55
56
try {
57
sm.checkPermission(new DebugPermission1("1"));
58
} catch (SecurityException se) {
59
throw new SecurityException("Test 3 Failed");
60
}
61
62
try {
63
sm.checkPermission(new DebugPermission2("1", "2"));
64
} catch (SecurityException se) {
65
throw new SecurityException("Test 4 Failed");
66
}
67
68
System.out.println("Test Succeeded");
69
}
70
}
71
72