Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove001.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.jdi.EventQueue.remove;
25
26
import com.sun.jdi.VirtualMachine;
27
import com.sun.jdi.request.EventRequest;
28
import com.sun.jdi.VMDisconnectedException;
29
import com.sun.jdi.event.*;
30
31
import java.io.*;
32
33
import nsk.share.*;
34
import nsk.share.jpda.*;
35
import nsk.share.jdi.*;
36
37
/**
38
* The test checks that a VMDisconnectedException thrown by
39
* the JDI method <b>com.sun.jdi.request.EventQueue.remove()</b>
40
* will always be preceded by a <code>VMDisconnectEvent</code>
41
* when a debuggee part of the test normally exits.
42
*/
43
public class remove001 {
44
public static final int PASSED = 0;
45
public static final int FAILED = 2;
46
public static final int JCK_STATUS_BASE = 95;
47
static final String DEBUGGEE_CLASS =
48
"nsk.jdi.EventQueue.remove.remove001t";
49
static final String COMMAND_READY = "ready";
50
static final String COMMAND_QUIT = "quit";
51
52
private ArgumentHandler argHandler;
53
private Log log;
54
private Debugee debuggee;
55
private int tot_res = FAILED;
56
57
public static void main(String argv[]) {
58
System.exit(run(argv,System.out) + JCK_STATUS_BASE);
59
}
60
61
public static int run(String argv[], PrintStream out) {
62
return new remove001().runIt(argv, out);
63
}
64
65
private int runIt(String args[], PrintStream out) {
66
argHandler = new ArgumentHandler(args);
67
log = new Log(out, argHandler);
68
Binder binder = new Binder(argHandler, log);
69
70
debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
71
debuggee.redirectStderr(log, "remove001t.err> ");
72
// dummy IOPipe: just to avoid:
73
// "Pipe server socket listening error: java.net.SocketException"
74
IOPipe pipe = debuggee.createIOPipe();
75
76
// Getting JDI events
77
checkEvents(debuggee.VM().eventQueue());
78
79
debuggee.waitFor();
80
int debStat = debuggee.getStatus();
81
if (debStat != (JCK_STATUS_BASE + PASSED)) {
82
log.complain("TEST FAILED: debuggee's process finished with status: "
83
+ debStat);
84
tot_res = FAILED;
85
} else
86
log.display("Debuggee's process finished with status: "
87
+ debStat);
88
89
return tot_res;
90
}
91
92
private void checkEvents(EventQueue eventQ) {
93
boolean gotVMDisconnect = false; // VMDisconnectEvent is received
94
boolean gotVMDeath = false; // VMDeathEvent is received
95
EventSet eventSet = null;
96
97
debuggee.resume();
98
while (true) {
99
try {
100
eventSet = eventQ.remove();
101
EventIterator eventIter = eventSet.eventIterator();
102
while (eventIter.hasNext()) {
103
Event event = eventIter.nextEvent();
104
if (event instanceof VMDisconnectEvent) {
105
gotVMDisconnect = true;
106
log.display("Got expected VMDisconnectEvent");
107
break;
108
} else if (event instanceof VMStartEvent) {
109
log.display("Got VMStartEvent");
110
} else if (event instanceof VMDeathEvent) {
111
gotVMDeath = true;
112
log.display("Got VMDeathEvent");
113
}
114
if (!gotVMDisconnect && !gotVMDeath &&
115
eventSet.suspendPolicy() !=
116
EventRequest.SUSPEND_NONE) {
117
log.display("Calling EventSet.resume() ...");
118
eventSet.resume();
119
}
120
}
121
} catch(InterruptedException e) {
122
log.complain("TEST INCOMPLETE: caught " + e);
123
tot_res = FAILED;
124
} catch(VMDisconnectedException e) {
125
if (gotVMDisconnect) {
126
log.display("\nCHECK PASSED: caught VMDisconnectedException preceded by a VMDisconnectEvent\n");
127
tot_res = PASSED;
128
} else {
129
log.complain("\nTEST FAILED: caught VMDisconnectedException without preceding VMDisconnectEvent\n");
130
e.printStackTrace();
131
tot_res = FAILED;
132
}
133
break;
134
}
135
}
136
log.display("Stopped JDI events processing");
137
}
138
}
139
140