Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/Dispose/dispose001.java
41161 views
1
/*
2
* Copyright (c) 2001, 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.jdwp.VirtualMachine.Dispose;
25
26
import java.io.*;
27
import java.util.*;
28
29
import nsk.share.*;
30
import nsk.share.jpda.*;
31
import nsk.share.jdwp.*;
32
33
public class dispose001 {
34
static final int JCK_STATUS_BASE = 95;
35
static final int PASSED = 0;
36
static final int FAILED = 2;
37
static final String PACKAGE_NAME = "nsk.jdwp.VirtualMachine.Dispose";
38
static final String TEST_CLASS_NAME = PACKAGE_NAME + "." + "dispose001";
39
static final String DEBUGEE_CLASS_NAME = TEST_CLASS_NAME + "a";
40
41
static final String JDWP_COMMAND_NAME = "VirtualMachine.Dispose";
42
static final int JDWP_COMMAND_ID = JDWP.Command.VirtualMachine.Dispose;
43
44
public static void main (String argv[]) {
45
System.exit(run(argv,System.out) + JCK_STATUS_BASE);
46
}
47
48
public static int run(String argv[], PrintStream out) {
49
return new dispose001().runIt(argv, out);
50
}
51
52
public int runIt(String argv[], PrintStream out) {
53
54
boolean success = true;
55
56
try {
57
final ArgumentHandler argumentHandler = new ArgumentHandler(argv);
58
final Log log = new Log(out, argumentHandler);
59
60
try {
61
62
Binder binder = new Binder(argumentHandler, log);
63
log.display("Start debugee VM");
64
final Debugee debugee = binder.bindToDebugee(DEBUGEE_CLASS_NAME);
65
Transport transport = debugee.getTransport();
66
IOPipe pipe = debugee.createIOPipe();
67
68
log.display("Waiting for VM_INIT event");
69
debugee.waitForVMInit();
70
71
log.display("Querying for IDSizes");
72
debugee.queryForIDSizes();
73
74
log.display("Resume debugee VM");
75
debugee.resume();
76
77
log.display("Waiting for command: " + "ready");
78
String cmd = pipe.readln();
79
log.display("Received command: " + cmd);
80
81
int bytesToWrite = 1024;
82
83
// begin test of JDWP command
84
85
try {
86
log.display("Creating command packet for " + JDWP_COMMAND_NAME);
87
CommandPacket command = new CommandPacket(JDWP_COMMAND_ID);
88
89
log.display("Sending command packet:\n" + command);
90
transport.write(command);
91
92
log.display("Waiting for reply packet");
93
ReplyPacket reply = new ReplyPacket();
94
transport.read(reply);
95
log.display("Reply packet received:\n" + reply);
96
97
log.display("Checking reply packet header");
98
reply.checkHeader(command.getPacketID());
99
100
log.display("Parsing reply packet:");
101
reply.resetPosition();
102
103
if (! reply.isParsed()) {
104
log.complain("Extra bytes in reply packet at: " + reply.currentPosition());
105
success = false;
106
}
107
108
log.display("Reply packet parsed successfully");
109
110
} catch (Exception e) {
111
log.complain("Exception catched: " + e);
112
success = false;
113
}
114
115
/*
116
// check if transport connection has been actually closed
117
118
if (success) {
119
120
log.display("Trying to write VirtualMachine.Version command packet "
121
+ "to the closed Transport connection");
122
123
try {
124
CommandPacket command = new CommandPacket(JDWP.Command.VirtualMachine.Version);
125
transport.write(command);
126
127
log.complain("Command packet successfully written to the closed transport channel\n"
128
+ "without any I/O exception thrown");
129
success = false;
130
} catch (IOException e) {
131
log.display("Caught expected IOException:\n\t" + e);
132
}
133
134
}
135
*/
136
137
// end test of JDWP command
138
139
log.display("Sending command: " + "quit");
140
pipe.println("quit");
141
142
log.display("Waiting for debugee exits");
143
int code = debugee.waitFor();
144
if (code == JCK_STATUS_BASE + PASSED) {
145
log.display("Debugee PASSED: " + code);
146
} else {
147
log.complain("Debugee FAILED: " + code);
148
success = false;
149
}
150
151
} catch (Exception e) {
152
log.complain("Unexpected exception: " + e);
153
e.printStackTrace(out);
154
success = false;
155
}
156
157
if (!success) {
158
log.complain("TEST FAILED");
159
return FAILED;
160
}
161
162
} catch (Exception e) {
163
out.println("Unexpected exception: " + e);
164
e.printStackTrace(out);
165
out.println("TEST FAILED");
166
return FAILED;
167
}
168
169
out.println("TEST PASSED");
170
return PASSED;
171
172
}
173
174
}
175
176