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