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