blob: 94d1e909bbad02e348953251d6b17ceb7b639f5a [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
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 */
36import com.sun.jdi.*;
37import com.sun.jdi.event.*;
38import com.sun.jdi.request.*;
39
40import java.util.*;
41
42 /********** target program **********/
43
44class 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
56public 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}