2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2002, 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 |
/**
|
|
25 |
* @test
|
|
26 |
* @bug 4528948
|
|
27 |
* @summary Unable to finish a debugging in NetBeans IDE
|
|
28 |
*
|
|
29 |
* @author jjh
|
|
30 |
*
|
|
31 |
* @library ..
|
|
32 |
* @run build TestScaffold VMConnection TargetListener TargetAdapter
|
|
33 |
* @run compile -g DeleteAllBkptsTest.java
|
|
34 |
* @run main DeleteAllBkptsTest
|
|
35 |
*/
|
|
36 |
import com.sun.jdi.*;
|
|
37 |
import com.sun.jdi.event.*;
|
|
38 |
import com.sun.jdi.request.*;
|
|
39 |
|
|
40 |
import java.util.*;
|
|
41 |
|
|
42 |
/********** target program **********/
|
|
43 |
|
|
44 |
class DeleteAllBkptsTarg {
|
|
45 |
public void gus() {
|
|
46 |
}
|
|
47 |
|
|
48 |
public static void main(String[] args){
|
|
49 |
System.out.println("Howdy!");
|
|
50 |
System.out.println("Goodbye from DeleteAllBkptsTarg!");
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
/********** test program **********/
|
|
55 |
|
|
56 |
public class DeleteAllBkptsTest extends TestScaffold {
|
|
57 |
ReferenceType targetClass;
|
|
58 |
ThreadReference mainThread;
|
|
59 |
|
|
60 |
DeleteAllBkptsTest (String args[]) {
|
|
61 |
super(args);
|
|
62 |
}
|
|
63 |
|
|
64 |
public static void main(String[] args) throws Exception {
|
|
65 |
new DeleteAllBkptsTest(args).startTests();
|
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
/********** test core **********/
|
|
70 |
|
|
71 |
protected void runTests() throws Exception {
|
|
72 |
/*
|
|
73 |
* Get to the top of main()
|
|
74 |
* to determine targetClass and mainThread
|
|
75 |
*/
|
|
76 |
BreakpointEvent bpe = startToMain("DeleteAllBkptsTarg");
|
|
77 |
targetClass = bpe.location().declaringType();
|
|
78 |
mainThread = bpe.thread();
|
|
79 |
EventRequestManager erm = vm().eventRequestManager();
|
|
80 |
|
|
81 |
|
|
82 |
Method method = findMethod(targetClass, "gus", "()V");
|
|
83 |
if (method == null) {
|
|
84 |
throw new IllegalArgumentException("Bad method name/signature");
|
|
85 |
}
|
|
86 |
BreakpointRequest request = erm.createBreakpointRequest(
|
|
87 |
method.location());
|
|
88 |
|
|
89 |
// This avoids the problem.
|
|
90 |
//request.enable();
|
|
91 |
|
|
92 |
try {
|
|
93 |
erm.deleteAllBreakpoints();
|
|
94 |
} catch (InternalException ee) {
|
|
95 |
// We get a failure here if no bkpts exist because of
|
|
96 |
// an un-init variable in BE function eventHandler_freeAll
|
|
97 |
failure("FAIL: Unexpected Exception encountered: " + ee);
|
|
98 |
}
|
|
99 |
|
|
100 |
/*
|
|
101 |
* resume the target listening for events
|
|
102 |
*/
|
|
103 |
listenUntilVMDisconnect();
|
|
104 |
|
|
105 |
/*
|
|
106 |
* deal with results of test
|
|
107 |
* if anything has called failure("foo") testFailed will be true
|
|
108 |
*/
|
|
109 |
if (!testFailed) {
|
|
110 |
println("DeleteAllBkptsTest: passed");
|
|
111 |
} else {
|
|
112 |
throw new Exception("DeleteAllBkptsTest: failed");
|
|
113 |
}
|
|
114 |
}
|
|
115 |
}
|