Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/action/Generify.java
41152 views
1
/*
2
* Copyright (c) 2004, 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 5057136
27
* @summary Generify sun.security.action.GetPropertyAction and friends
28
* @modules java.base/sun.security.action
29
*/
30
31
import java.io.*;
32
import java.security.*;
33
import sun.security.action.*;
34
35
public class Generify {
36
37
public static void main(String[] args) throws Exception {
38
39
long larg = 1234567890L;
40
41
System.setProperty("boolean", "true");
42
System.setProperty("integer", "9");
43
System.setProperty("long", Long.toString(larg));
44
System.setProperty("property", "propertyvalue");
45
46
Boolean b = AccessController.doPrivileged
47
(new GetBooleanAction("boolean"));
48
if (b.booleanValue() == true) {
49
System.out.println("boolean test passed");
50
} else {
51
throw new SecurityException("boolean test failed");
52
}
53
54
Integer i = AccessController.doPrivileged
55
(new GetIntegerAction("integer"));
56
if (i.intValue() == 9) {
57
System.out.println("integer test passed");
58
} else {
59
throw new SecurityException("integer test failed");
60
}
61
62
Long l = AccessController.doPrivileged
63
(new GetLongAction("long"));
64
if (l.longValue() == larg) {
65
System.out.println("long test passed");
66
} else {
67
throw new SecurityException("long test failed");
68
}
69
70
String prop = AccessController.doPrivileged
71
(new GetPropertyAction("property"));
72
if (prop.equals("propertyvalue")) {
73
System.out.println("property test passed");
74
} else {
75
throw new SecurityException("property test failed");
76
}
77
78
File f = new File(System.getProperty("test.src", "."), "Generify.java");
79
FileInputStream fis = AccessController.doPrivileged
80
(new OpenFileInputStreamAction(f));
81
if (fis != null) {
82
System.out.println("file test passed");
83
} else {
84
throw new SecurityException("file test failed");
85
}
86
}
87
}
88
89