author | amenkov |
Fri, 21 Sep 2018 11:28:14 -0700 | |
changeset 51837 | 46ca82c15f6c |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
30376
2ccf2cf7ea48
8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents:
24973
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/** |
|
44423 | 25 |
* @test |
26 |
* @bug 4425852 |
|
27 |
* @author Robert Field |
|
2 | 28 |
* |
44423 | 29 |
* @summary EventQueueDisconnectTest checks to see that |
30 |
* VMDisconnectedException is never thrown before VMDisconnectEvent. |
|
2 | 31 |
* |
32 |
* Failure mode for this test is throwing VMDisconnectedException |
|
33 |
* on vm.eventQueue().remove(); |
|
34 |
* Does not use a scaffold since we don't want that hiding the exception. |
|
44423 | 35 |
* |
36 |
* @run build VMConnection |
|
37 |
* @run compile -g EventQueueDisconnectTest.java |
|
38 |
* @run driver EventQueueDisconnectTest |
|
2 | 39 |
*/ |
40 |
import com.sun.jdi.*; |
|
41 |
import com.sun.jdi.event.*; |
|
42 |
import com.sun.jdi.request.*; |
|
43 |
||
44 |
||
45 |
/********** target program **********/ |
|
46 |
||
47 |
class EventQueueDisconnectTarg { |
|
48 |
public static void main(String args[]) { |
|
49 |
for (int i=0; i < 10; ++i) { |
|
50 |
Say(i); |
|
51 |
} |
|
52 |
} |
|
53 |
static void Say(int what) { |
|
54 |
System.out.println("Say " + what); |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
/********** test program **********/ |
|
59 |
||
60 |
public class EventQueueDisconnectTest { |
|
61 |
||
62 |
public static void main(String args[]) throws Exception { |
|
63 |
VMConnection connection = new VMConnection( |
|
64 |
"com.sun.jdi.CommandLineLaunch:", |
|
65 |
VirtualMachine.TRACE_NONE); |
|
66 |
connection.setConnectorArg("main", "EventQueueDisconnectTarg"); |
|
24973
8c4bc3fa4c4e
6622468: TEST_BUG: Time to retire the @debuggeeVMOptions mechanism used in the com.sun.jdi infrastructure
sla
parents:
5506
diff
changeset
|
67 |
String debuggeeVMOptions = VMConnection.getDebuggeeVMOptions(); |
2 | 68 |
if (!debuggeeVMOptions.equals("")) { |
69 |
if (connection.connectorArg("options").length() > 0) { |
|
70 |
throw new IllegalArgumentException("VM options in two places"); |
|
71 |
} |
|
72 |
connection.setConnectorArg("options", debuggeeVMOptions); |
|
73 |
} |
|
74 |
VirtualMachine vm = connection.open(); |
|
75 |
EventRequestManager requestManager = vm.eventRequestManager(); |
|
76 |
MethodEntryRequest req = requestManager.createMethodEntryRequest(); |
|
77 |
req.addClassFilter("EventQueueDisconnectTarg"); |
|
78 |
req.setSuspendPolicy(EventRequest.SUSPEND_NONE); |
|
79 |
req.enable(); |
|
80 |
||
81 |
// We need to have the BE stop when VMDeath comes |
|
82 |
VMDeathRequest ourVMDeathRequest = requestManager.createVMDeathRequest(); |
|
83 |
ourVMDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL); |
|
84 |
ourVMDeathRequest.enable(); |
|
85 |
||
86 |
vm.resume(); |
|
87 |
while (true) { |
|
88 |
EventSet set = vm.eventQueue().remove(); |
|
89 |
Event event = set.eventIterator().nextEvent(); |
|
90 |
||
91 |
System.err.println("EventSet with: " + event.getClass()); |
|
92 |
||
93 |
if (event instanceof VMDisconnectEvent) { |
|
94 |
System.err.println("Disconnecting successfully"); |
|
95 |
break; |
|
96 |
} |
|
97 |
||
98 |
if (event instanceof VMDeathEvent) { |
|
99 |
System.err.println("Pausing after VM death"); |
|
100 |
||
101 |
// sleep a few seconds |
|
102 |
try { |
|
103 |
Thread.sleep(40 * 1000); |
|
104 |
} catch (InterruptedException exc) { |
|
105 |
// ignore |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
set.resume(); |
|
110 |
} |
|
111 |
||
112 |
System.err.println("EventQueueDisconnectTest passed"); |
|
113 |
} |
|
114 |
} |