Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/AllThreads/allthreads001.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.AllThreads;
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 allthreads001 {
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.AllThreads";
38
static final String TEST_CLASS_NAME = PACKAGE_NAME + "." + "allthreads001";
39
static final String DEBUGEE_CLASS_NAME = TEST_CLASS_NAME + "a";
40
41
static final String JDWP_COMMAND_NAME = "VirtualMachine.AllThreads";
42
static final int JDWP_COMMAND_ID = JDWP.Command.VirtualMachine.AllThreads;
43
44
static final String TESTED_CLASS_NAME = DEBUGEE_CLASS_NAME;
45
46
public static void main (String argv[]) {
47
System.exit(run(argv,System.out) + JCK_STATUS_BASE);
48
}
49
50
public static int run(String argv[], PrintStream out) {
51
return new allthreads001().runIt(argv, out);
52
}
53
54
public int runIt(String argv[], PrintStream out) {
55
56
boolean success = true;
57
58
try {
59
ArgumentHandler argumentHandler = new ArgumentHandler(argv);
60
Log log = new Log(out, argumentHandler);
61
62
try {
63
64
Binder binder = new Binder(argumentHandler, log);
65
log.display("Start debugee VM");
66
Debugee debugee = binder.bindToDebugee(DEBUGEE_CLASS_NAME);
67
Transport transport = debugee.getTransport();
68
IOPipe pipe = debugee.createIOPipe();
69
70
log.display("Waiting for VM_INIT event");
71
debugee.waitForVMInit();
72
73
log.display("Querying for IDSizes");
74
debugee.queryForIDSizes();
75
76
log.display("Resume debugee VM");
77
debugee.resume();
78
79
log.display("Waiting for command: " + "ready");
80
String cmd = pipe.readln();
81
log.display("Received command: " + cmd);
82
83
String classSignature = "L" + TESTED_CLASS_NAME.replace('.', '/') + ";";
84
85
// begin test of JDWP command
86
87
try {
88
CommandPacket command = new CommandPacket(JDWP_COMMAND_ID);
89
90
log.display("Sending command packet:\n" + command);
91
transport.write(command);
92
93
log.display("Waiting for reply packet");
94
ReplyPacket reply = new ReplyPacket();
95
transport.read(reply);
96
log.display("Reply packet received:\n" + reply);
97
98
log.display("Checking reply packet header");
99
reply.checkHeader(command.getPacketID());
100
101
log.display("Parsing reply packet:");
102
reply.resetPosition();
103
104
int threads = reply.getInt();
105
log.display(" threads: " + threads);
106
107
if (threads < 0) {
108
log.complain("Negative number of returned threads: " + threads);
109
success = false;
110
}
111
112
if (threads == 0) {
113
log.complain("No threads returned");
114
success = false;
115
}
116
117
for (int i = 0; i < threads; i++) {
118
long threadID = reply.getObjectID();
119
log.display(" " + i + " threadID: " + threadID);
120
}
121
122
if (! reply.isParsed()) {
123
log.complain("Extra bytes in reply packet at: "
124
+ reply.currentPosition());
125
success = false;
126
}
127
128
} catch (Exception e) {
129
log.complain("Exception catched: " + e);
130
success = false;
131
}
132
133
// end test of JDWP command
134
135
log.display("Sending command: " + "quit");
136
pipe.println("quit");
137
138
log.display("Waiting for debugee exits");
139
int code = debugee.waitFor();
140
if (code == JCK_STATUS_BASE + PASSED) {
141
log.display("Debugee PASSED: " + code);
142
} else {
143
log.complain("Debugee FAILED: " + code);
144
success = false;
145
}
146
147
} catch (Exception e) {
148
log.complain("Unexpected exception: " + e);
149
e.printStackTrace(out);
150
success = false;
151
}
152
153
if (!success) {
154
log.complain("TEST FAILED");
155
return FAILED;
156
}
157
158
} catch (Exception e) {
159
out.println("Unexpected exception: " + e);
160
e.printStackTrace(out);
161
out.println("TEST FAILED");
162
return FAILED;
163
}
164
165
out.println("TEST PASSED");
166
return PASSED;
167
168
}
169
170
}
171
172