Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/isValid/isvalid002.java
41160 views
1
/*
2
* Copyright (c) 2000, 2018, 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
package nsk.jdi.Argument.isValid;
25
26
import java.io.PrintStream;
27
import java.io.Serializable;
28
29
import java.util.Map;
30
import java.util.Set;
31
import java.util.List;
32
import java.util.Iterator;
33
import java.util.NoSuchElementException;
34
35
import com.sun.jdi.VirtualMachineManager;
36
import com.sun.jdi.Bootstrap;
37
import com.sun.jdi.connect.Connector;
38
import com.sun.jdi.connect.Connector.Argument;
39
import com.sun.jdi.connect.Connector.BooleanArgument;
40
41
/**
42
* The test for the implementation of an object of the type <BR>
43
* Connector.Argument. <BR>
44
* <BR>
45
* The test checks up that results of the method <BR>
46
* <code>com.sun.jdi.connect.Connector.Argument.isValid()</code> <BR>
47
* complies with its specification. <BR>
48
* The case for testing includes throwing NullPointerException <BR>
49
* if a parameter is a null-string. <BR>
50
* <BR>
51
*/
52
53
54
public class isvalid002 {
55
56
public static void main(String argv[]) {
57
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
58
}
59
60
public static int run(String argv[], PrintStream out) {
61
62
int exitCode = 0;
63
int exitCode0 = 0;
64
int exitCode2 = 2;
65
//
66
String sErr1 = "WARNING\n" +
67
"Method tested: " +
68
"jdi.Connector.Argument.isValid\n" ;
69
//
70
String sErr2 = "ERROR\n" +
71
"Method tested: " +
72
"jdi.Connector.Argument.isValid\n" ;
73
74
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
75
76
List connectorsList = vmm.allConnectors();
77
Iterator connectorsListIterator = connectorsList.iterator();
78
//
79
Connector.Argument argument = null;
80
Connector.BooleanArgument booleanArg = null;
81
82
for ( ; ; ) {
83
try {
84
Connector connector =
85
(Connector) connectorsListIterator.next();
86
87
Map defaultArguments = connector.defaultArguments();
88
Set keyset = defaultArguments.keySet();
89
int keysetSize = defaultArguments.size();
90
Iterator keysetIterator = keyset.iterator();
91
92
for ( ; ; ) {
93
try {
94
String argName = (String) keysetIterator.next();
95
96
try {
97
argument = (Connector.Argument)
98
defaultArguments.get(argName);
99
try {
100
booleanArg = (Connector.BooleanArgument)
101
defaultArguments.get(argName);
102
break ;
103
} catch ( ClassCastException e) {
104
}
105
} catch ( ClassCastException e) {
106
}
107
} catch ( NoSuchElementException e) {
108
break ;
109
}
110
}
111
if (booleanArg != null) {
112
break ;
113
}
114
} catch ( NoSuchElementException e) {
115
out.println(sErr1 +
116
"no Connector with BooleanArgument found\n");
117
return exitCode0;
118
}
119
}
120
121
String sNull = null;
122
try {
123
argument.isValid(sNull);
124
exitCode = exitCode2;
125
out.println(sErr2 +
126
"check: isValid(sNull)\n" +
127
"ERROR: no NullPointerException thrown");
128
} catch ( NullPointerException e ) {
129
}
130
131
if (exitCode != exitCode0)
132
out.println("TEST FAILED");
133
134
return exitCode;
135
}
136
}
137
138