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/isvalid004.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.IntegerArgument;
39
40
41
/**
42
* The test for the implementation of an object of the type <BR>
43
* Connector_IntegerArgument. <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, that is, <BR>
48
* "Returns: true if the value is valid to be used in setValue(String)" <BR>
49
* in case when Argument implements IntegerArgument <BR>
50
* and its parameter is a string representing one of min(), max(), <BR>
51
* min()-1, min()+1, max()+1. <BR>
52
* <BR>
53
* In case of a wrong result returned, <BR>
54
* the test produces the return value 97 and <BR>
55
* a corresponding error message. <BR>
56
* Otherwise, the test is passed and produces <BR>
57
* the return value 95 and no message. <BR>
58
*/
59
60
//
61
public class isvalid004 {
62
63
public static void main(String argv[]) {
64
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
65
}
66
67
public static int run(String argv[], PrintStream out) {
68
69
int exitCode = 0;
70
int exitCode0 = 0;
71
int exitCode2 = 2;
72
//
73
String sErr1 = "WARNING\n" +
74
"Method tested: " +
75
"jdi.Connector.Argument.isValid\n" ;
76
//
77
String sErr2 = "ERROR\n" +
78
"Method tested: " +
79
"jdi.Connector.Argument.isValid\n" ;
80
81
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
82
83
List connectorsList = vmm.allConnectors();
84
Iterator connectorsListIterator = connectorsList.iterator();
85
//
86
Connector.Argument argument = null;
87
Connector.IntegerArgument intArgument = null;
88
89
for ( ; ; ) {
90
try {
91
Connector connector =
92
(Connector) connectorsListIterator.next();
93
94
Map defaultArguments = connector.defaultArguments();
95
Set keyset = defaultArguments.keySet();
96
int keysetSize = defaultArguments.size();
97
Iterator keysetIterator = keyset.iterator();
98
99
for ( ; ; ) {
100
try {
101
String argName = (String) keysetIterator.next();
102
103
try {
104
//
105
argument = (Connector.IntegerArgument)
106
defaultArguments.get(argName);
107
try {
108
intArgument = (Connector.IntegerArgument)
109
defaultArguments.get(argName);
110
break ;
111
} catch ( ClassCastException e) {
112
}
113
} catch ( ClassCastException e) {
114
}
115
} catch ( NoSuchElementException e) {
116
break ;
117
}
118
}
119
if (intArgument != null) {
120
break ;
121
}
122
} catch ( NoSuchElementException e) {
123
out.println(sErr1 +
124
//
125
"no Connector with IntegerArgument found\n");
126
return exitCode0;
127
}
128
}
129
130
Integer intI = null;
131
132
if (argument.isValid(intArgument.stringValueOf(intArgument.min()))) {
133
} else {
134
exitCode = exitCode2;
135
out.println(sErr2 +
136
"check: super.isValid(stringValueOf(min()))\n" +
137
"result: false\n");
138
}
139
140
if (argument.isValid(intArgument.stringValueOf(intArgument.max()))) {
141
} else {
142
exitCode = exitCode2;
143
out.println(sErr2 +
144
"check: super.isValid(stringValueOf(max()))\n" +
145
"result: false\n");
146
}
147
148
if (intArgument.min() < intArgument.max()) {
149
if (argument.isValid(
150
intArgument.stringValueOf(intArgument.min() + 1))) {
151
} else {
152
exitCode = exitCode2;
153
out.println(sErr2 +
154
"check: super.isValid(stringValueOf(min()+1))\n" +
155
"result: false\n");
156
}
157
}
158
159
if (intArgument.min() > intI.MIN_VALUE) {
160
if (!argument.isValid(
161
intArgument.stringValueOf(intArgument.min() - 1))) {
162
} else {
163
exitCode = exitCode2;
164
out.println(sErr2 +
165
"check: super.isValid(stringValueOf(min()-1))\n" +
166
"result: true\n");
167
}
168
}
169
170
if (intArgument.max() < intI.MAX_VALUE) {
171
if (!argument.isValid(
172
intArgument.stringValueOf(intArgument.max() + 1))) {
173
} else {
174
exitCode = exitCode2;
175
out.println(sErr2 +
176
"check: super.isValid(stringValueOf(max()+1))\n" +
177
"result: true\n");
178
}
179
}
180
181
182
if (exitCode != exitCode0) {
183
out.println("TEST FAILED");
184
}
185
return exitCode;
186
}
187
}
188
189