Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/setValue/setvalue002.java
41161 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.BooleanArgument.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.Argument;
39
import com.sun.jdi.connect.Connector.BooleanArgument;
40
41
42
/**
43
* The second test for the implementation of a BooleanArgument object. <BR>
44
*
45
* The test checks up that results of the method <BR>
46
* <code>com.sun.jdi.connect.Connector.BooleanArgument.setValue()</code> <BR>
47
* complies with specification. <BR>
48
* The test works as follows: <BR>
49
* <BR>
50
* - Virtual Machine Manager is invoked. <BR>
51
* - First BooleanArgument is searched among Connectors. <BR>
52
* If no BooleanArgument is found out the test exits with <BR>
53
* the return value = 95 and a warning message. <BR>
54
* - Under the assumption that the method <BR>
55
* BooleanArgument.booleanValue() works correctly (!!), <BR>
56
* to the value of the BooleanArgument founded, <BR>
57
* which may not have been set or may have an invalid value, <BR>
58
* the following check is applied: <BR>
59
* <BR>
60
* setValue(true); booleanValue() must return true; <BR>
61
* <BR>
62
* In case of the check results in a wrong value, <BR>
63
* the test produces the return value 97 and <BR>
64
* a corresponding error message. <BR>
65
* Otherwise, the test is passed and produces <BR>
66
* the return value 95 and no message. <BR>
67
*/
68
69
70
public class setvalue002 {
71
72
public static void main(String argv[]) {
73
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
74
}
75
76
public static int run(String argv[], PrintStream out) {
77
78
int exitCode = 0;
79
int exitCode0 = 0;
80
int exitCode2 = 2;
81
//
82
String sErr1 = "WARNING\n" +
83
"Method tested: " +
84
"jdi.Connector.BooleanArgument.setValue\n" ;
85
//
86
String sErr2 = "ERROR\n" +
87
"Method tested: " +
88
"jdi.Connector.BooleanArgument.setValue\n" ;
89
90
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
91
92
List connectorsList = vmm.allConnectors();
93
Iterator connectorsListIterator = connectorsList.iterator();
94
//
95
Connector.BooleanArgument argument = null;
96
97
for ( ; ; ) {
98
try {
99
Connector connector =
100
(Connector) connectorsListIterator.next();
101
102
Map defaultArguments = connector.defaultArguments();
103
Set keyset = defaultArguments.keySet();
104
int keysetSize = defaultArguments.size();
105
Iterator keysetIterator = keyset.iterator();
106
107
for ( ; ; ) {
108
try {
109
String argName = (String) keysetIterator.next();
110
111
try {
112
//
113
argument = (Connector.BooleanArgument)
114
defaultArguments.get(argName);
115
break ;
116
} catch ( ClassCastException e) {
117
}
118
} catch ( NoSuchElementException e) {
119
break ;
120
}
121
}
122
if (argument != null) {
123
break ;
124
}
125
} catch ( NoSuchElementException e) {
126
out.println(sErr1 +
127
"no Connector with BooleanArgument found\n");
128
return exitCode0;
129
}
130
}
131
132
// initial -> false
133
argument.setValue(false);
134
if (argument.booleanValue() != false) {
135
exitCode = 2;
136
out.println(sErr2 +
137
"case: initial -> false\n" +
138
"error: a returned value != false");
139
}
140
141
if (exitCode != exitCode0)
142
out.println("TEST FAILED");
143
144
return exitCode;
145
}
146
}
147
148