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