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