Path: blob/master/test/jdk/com/sun/jdi/DeleteAllBkptsTest.java
41149 views
/*1* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 452894826* @summary Unable to finish a debugging in NetBeans IDE27* @author jjh28*29* @library ..30*31* @run build TestScaffold VMConnection TargetListener TargetAdapter32* @run compile -g DeleteAllBkptsTest.java33* @run driver DeleteAllBkptsTest34*/35import com.sun.jdi.*;36import com.sun.jdi.event.*;37import com.sun.jdi.request.*;3839import java.util.*;4041/********** target program **********/4243class DeleteAllBkptsTarg {44public void gus() {45}4647public static void main(String[] args){48System.out.println("Howdy!");49System.out.println("Goodbye from DeleteAllBkptsTarg!");50}51}5253/********** test program **********/5455public class DeleteAllBkptsTest extends TestScaffold {56ReferenceType targetClass;57ThreadReference mainThread;5859DeleteAllBkptsTest (String args[]) {60super(args);61}6263public static void main(String[] args) throws Exception {64new DeleteAllBkptsTest(args).startTests();65}666768/********** test core **********/6970protected void runTests() throws Exception {71/*72* Get to the top of main()73* to determine targetClass and mainThread74*/75BreakpointEvent bpe = startToMain("DeleteAllBkptsTarg");76targetClass = bpe.location().declaringType();77mainThread = bpe.thread();78EventRequestManager erm = vm().eventRequestManager();798081Method method = findMethod(targetClass, "gus", "()V");82if (method == null) {83throw new IllegalArgumentException("Bad method name/signature");84}85BreakpointRequest request = erm.createBreakpointRequest(86method.location());8788// This avoids the problem.89//request.enable();9091try {92erm.deleteAllBreakpoints();93} catch (InternalException ee) {94// We get a failure here if no bkpts exist because of95// an un-init variable in BE function eventHandler_freeAll96failure("FAIL: Unexpected Exception encountered: " + ee);97}9899/*100* resume the target listening for events101*/102listenUntilVMDisconnect();103104/*105* deal with results of test106* if anything has called failure("foo") testFailed will be true107*/108if (!testFailed) {109println("DeleteAllBkptsTest: passed");110} else {111throw new Exception("DeleteAllBkptsTest: failed");112}113}114}115116117