Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanArgument/stringValueOf/stringvalueof001.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.stringValueOf;
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 test for the implementation of an object of the type <BR>
44
* Connector.BooleanArgument. <BR>
45
* <BR>
46
* The test checks up that results of the method <BR>
47
* Connector.BooleanArgument.stringValueOf(boolean value) <BR>
48
* in the package com.sun.jdi.connect <BR>
49
* complies with the following statement in its specification: <BR>
50
* "Return the string representation of the value parameter." <BR>
51
* <BR>
52
* In case of the check results in a wrong value, <BR>
53
* the test produces the return value 97 and <BR>
54
* a corresponding error message. <BR>
55
* Otherwise, the test is passed and produces <BR>
56
* the return value 95 and no message. <BR>
57
*/
58
59
60
public class stringvalueof001 {
61
public static void main(String argv[]) {
62
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
63
}
64
65
public static int run(String argv[], PrintStream out) {
66
67
int exitCode = 0;
68
int exitCode0 = 0;
69
int exitCode2 = 2;
70
//
71
String sErr1 = "WARNING\n" +
72
"Method tested: " +
73
"jdi.Connector.BooleanArgument.stringValueOf\n" ;
74
//
75
String sErr2 = "ERROR\n" +
76
"Method tested: " +
77
"jdi.Connector.BooleanArgument.stringValueof\n" ;
78
79
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
80
81
List connectorsList = vmm.allConnectors();
82
Iterator connectorsListIterator = connectorsList.iterator();
83
//
84
Connector.BooleanArgument argument = null;
85
86
for ( ; ; ) {
87
try {
88
Connector connector =
89
(Connector) connectorsListIterator.next();
90
91
Map defaultArguments = connector.defaultArguments();
92
Set keyset = defaultArguments.keySet();
93
int keysetSize = defaultArguments.size();
94
Iterator keysetIterator = keyset.iterator();
95
96
for ( ; ; ) {
97
try {
98
String argName = (String) keysetIterator.next();
99
100
try {
101
//
102
argument = (Connector.BooleanArgument)
103
defaultArguments.get(argName);
104
break ;
105
} catch ( ClassCastException e) {
106
}
107
} catch ( NoSuchElementException e) {
108
break ;
109
}
110
}
111
if (argument != null) {
112
break ;
113
}
114
} catch ( NoSuchElementException e) {
115
out.println(sErr1 +
116
"no Connector with BooleanArgument found\n");
117
return exitCode0;
118
}
119
}
120
121
String sTrue = argument.stringValueOf(true);
122
String sFalse = argument.stringValueOf(false);
123
124
if (sTrue.equalsIgnoreCase(sFalse)) {
125
exitCode = 2;
126
out.println(sErr2 +
127
"check: stringValueOf(true) != stringValueOf(false)\n" +
128
"error: strings are equal\n");
129
}
130
131
if (sTrue == null) {
132
exitCode = 2;
133
out.println(sErr2 +
134
"check: stringValueOf(true) = 'true'\n" +
135
"error: a returned value = null\n");
136
}
137
138
if (sFalse == null) {
139
exitCode = 2;
140
out.println(sErr2 +
141
"check: stringValueOf(false) = 'false'\n" +
142
"error: a returned value = null\n");
143
}
144
145
if (exitCode != exitCode0)
146
out.println("TEST FAILED");
147
148
return exitCode;
149
}
150
}
151
152