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/intvalue001.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
* "Returns the value of the argument as a int." <BR>
49
* when the value of IntegerArgument is set <BR>
50
* with the method setValue(int 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 a value set with setValue() <BR>
59
* doesn't match a value get with the following intValue(), <BR>
60
* the test produces the return value 97 and <BR>
61
* a corresponding error message. <BR>
62
* Otherwise, the test is passed and produces <BR>
63
* the return value 95 and no message. <BR>
64
*/
65
66
//
67
public class intvalue001 {
68
69
public static void main(String argv[]) {
70
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
71
}
72
73
public static int run(String argv[], PrintStream out) {
74
75
int exitCode = 0;
76
int exitCode0 = 0;
77
int exitCode2 = 2;
78
//
79
String sErr1 = "WARNING\n" +
80
"Method tested: " +
81
"jdi.Connector.IntegerArgument.intValue\n" ;
82
//
83
String sErr2 = "ERROR\n" +
84
"Method tested: " +
85
"jdi.Connector.IntegerArgument.intValue()\n" ;
86
87
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
88
89
List connectorsList = vmm.allConnectors();
90
Iterator connectorsListIterator = connectorsList.iterator();
91
//
92
Connector.IntegerArgument intArgument = null;
93
94
for ( ; ; ) {
95
try {
96
Connector connector =
97
(Connector) connectorsListIterator.next();
98
99
Map defaultArguments = connector.defaultArguments();
100
Set keyset = defaultArguments.keySet();
101
int keysetSize = defaultArguments.size();
102
Iterator keysetIterator = keyset.iterator();
103
104
for ( ; ; ) {
105
try {
106
String argName = (String) keysetIterator.next();
107
108
try {
109
//
110
intArgument = (Connector.IntegerArgument)
111
defaultArguments.get(argName);
112
break ;
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
int i;
132
133
i = intArgument.min();
134
intArgument.setValue(i);
135
if (intArgument.intValue() != i) {
136
exitCode = exitCode2;
137
out.println(sErr2 +
138
"check: setValue(min()); intValue() == min()\n" +
139
"result: false\n");
140
}
141
142
i = intArgument.max();
143
intArgument.setValue(i);
144
if (intArgument.intValue() != i) {
145
exitCode = exitCode2;
146
out.println(sErr2 +
147
"check: setValue(max()); intValue() == max()\n" +
148
"result: false\n");
149
}
150
151
if (intArgument.min() < intArgument.max()) {
152
i = intArgument.min() + 1;
153
intArgument.setValue(i);
154
if (intArgument.intValue() != i) {
155
exitCode = exitCode2;
156
out.println(sErr2 +
157
"check: setValue(min()+1); intValue() == min()+1\n" +
158
"result: false\n");
159
}
160
}
161
162
if (intArgument.min() > intI.MIN_VALUE) {
163
i = intArgument.min() - 1;
164
intArgument.setValue(i);
165
if (intArgument.intValue() != i) {
166
exitCode = exitCode2;
167
out.println(sErr2 +
168
"check: setValue(min()-1); intValue() == min()-1\n" +
169
"result: false\n");
170
}
171
}
172
173
if (intArgument.max() < intI.MAX_VALUE) {
174
i = intArgument.max() + 1;
175
intArgument.setValue(i);
176
if (intArgument.intValue() != i) {
177
exitCode = exitCode2;
178
out.println(sErr2 +
179
"check: setValue(max()+1); intValue() == max()+1\n" +
180
"result: false\n");
181
}
182
}
183
184
if (exitCode != exitCode0) {
185
out.println("TEST FAILED");
186
}
187
return exitCode;
188
}
189
}
190
191