Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/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.Argument.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 java.lang.NullPointerException;
36
37
import com.sun.jdi.VirtualMachineManager;
38
import com.sun.jdi.Bootstrap;
39
import com.sun.jdi.connect.Connector;
40
import com.sun.jdi.connect.Connector.Argument;
41
42
43
/**
44
* The test for the implementation of an object of the type <BR>
45
* Connector.Argument. <BR>
46
*
47
* The test checks up that results of the method <BR>
48
* <code>com.sun.jdi.connect.Connector.Argument.setValue()</code> <BR>
49
* complies with its specification. <BR>
50
* The case for testing includes throwing NullPointerException <BR>
51
* if a parameter is null-string. <BR>
52
* <BR>
53
*/
54
55
56
public class setvalue001 {
57
58
public static void main(String argv[]) {
59
System.exit(run(argv, System.out) + 95); // JCK-compatible exit status
60
}
61
62
public static int run(String argv[], PrintStream out) {
63
64
int exitCode = 0;
65
int exitCode0 = 0;
66
int exitCode2 = 2;
67
//
68
String sErr1 = "WARNING\n" +
69
"Method tested: " +
70
"jdi.Connector.Argument.setValue()\n" ;
71
//
72
String sErr2 = "ERROR\n" +
73
"Method tested: " +
74
"jdi.Connector.Argument.setValue()\n" ;
75
76
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
77
78
List connectorsList = vmm.allConnectors();
79
Iterator connectorsListIterator = connectorsList.iterator();
80
//
81
Connector.Argument argument = null;
82
83
for ( ; ; ) {
84
try {
85
Connector connector =
86
(Connector) connectorsListIterator.next();
87
88
Map defaultArguments = connector.defaultArguments();
89
Set keyset = defaultArguments.keySet();
90
int keysetSize = defaultArguments.size();
91
Iterator keysetIterator = keyset.iterator();
92
93
for ( ; ; ) {
94
try {
95
String argName = (String) keysetIterator.next();
96
97
try {
98
//
99
argument = (Connector.Argument)
100
defaultArguments.get(argName);
101
break ;
102
} catch ( ClassCastException e) {
103
}
104
} catch ( NoSuchElementException e) {
105
break ;
106
}
107
}
108
if (argument != null) {
109
break ;
110
}
111
} catch ( NoSuchElementException e) {
112
out.println(sErr1 +
113
"no Connecter with Argument found\n");
114
return exitCode0;
115
}
116
}
117
118
try {
119
argument.setValue(null);
120
exitCode = exitCode2;
121
out.println(sErr2 +
122
"check: setValue(null); \n" +
123
"error: no NullPointerException thrown\n");
124
} catch ( java.lang.NullPointerException e ) {
125
}
126
127
if (exitCode != exitCode0)
128
out.println("TEST FAILED");
129
130
return exitCode;
131
}
132
}
133
134