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