Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/security/Security/Nulls.java
41149 views
1
/*
2
* Copyright (c) 2003, 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 4960208
27
* @summary verify behavior passing null to various java.security.Security methods
28
* @author Andreas Sterbenz
29
*/
30
31
import java.util.*;
32
33
import java.security.*;
34
35
public class Nulls {
36
37
public static void main(String[] args) throws Exception {
38
try {
39
Security.addProvider(null);
40
throw new Exception();
41
} catch (NullPointerException e) {
42
System.out.println("addProvider(null): " + e);
43
}
44
if (Security.getAlgorithms(null).isEmpty() == false) {
45
throw new Exception();
46
}
47
try {
48
Security.getProperty(null);
49
throw new Exception();
50
} catch (NullPointerException e) {
51
System.out.println("getProperty(null): " + e);
52
}
53
if (Security.getProvider(null) != null) {
54
throw new Exception();
55
}
56
try {
57
Security.getProviders((Map)null);
58
throw new Exception();
59
} catch (NullPointerException e) {
60
System.out.println("getProviders((Map)null): " + e);
61
}
62
try {
63
Security.getProviders((String)null);
64
throw new Exception();
65
} catch (NullPointerException e) {
66
System.out.println("getProviders((String)null): " + e);
67
}
68
try {
69
Security.insertProviderAt(null, 1);
70
throw new Exception();
71
} catch (NullPointerException e) {
72
System.out.println("insertProviderAt(null): " + e);
73
}
74
Security.removeProvider(null);
75
try {
76
Security.setProperty("foo", null);
77
throw new Exception();
78
} catch (NullPointerException e) {
79
System.out.println("setProperty(\"foo\", null): " + e);
80
}
81
try {
82
Security.setProperty(null, "foo");
83
throw new Exception();
84
} catch (NullPointerException e) {
85
System.out.println("setProperty(null, \"foo\"): " + e);
86
}
87
try {
88
Security.setProperty(null, null);
89
throw new Exception();
90
} catch (NullPointerException e) {
91
System.out.println("setProperty(null, null): " + e);
92
}
93
if (Security.getAlgorithmProperty(null, null) != null) {
94
throw new Exception();
95
}
96
}
97
98
}
99
100