Path: blob/master/test/jdk/com/sun/jdi/DeleteEventRequestsTest.java
41149 views
/*1* Copyright (c) 2001, 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 433187226* @summary erm.deleteEventRequests(erm.breakpointRequests()) throws exception27* @author Robert Field28*29* @run build TestScaffold VMConnection TargetListener TargetAdapter30* @run compile -g DeleteEventRequestsTest.java31* @run driver DeleteEventRequestsTest32*/33import com.sun.jdi.*;34import com.sun.jdi.event.*;35import com.sun.jdi.request.*;3637import java.util.*;3839/********** target program **********/4041class DeleteEventRequestsTarg {42public static void main(String[] args){43System.out.println("Howdy!");44System.out.println("Goodbye from DeleteEventRequestsTarg!");45}46}4748/********** test program **********/4950public class DeleteEventRequestsTest extends TestScaffold {51ReferenceType targetClass;52ThreadReference mainThread;5354DeleteEventRequestsTest (String args[]) {55super(args);56}5758public static void main(String[] args) throws Exception {59new DeleteEventRequestsTest(args).startTests();60}6162/********** event handlers **********/6364public void stepCompleted(StepEvent event) {65failure("Got StepEvent which was deleted");66}6768/********** test core **********/6970protected void runTests() throws Exception {71/*72* Get to the top of main()73* to determine targetClass and mainThread74*/75BreakpointEvent bpe = startToMain("DeleteEventRequestsTarg");76targetClass = bpe.location().declaringType();77mainThread = bpe.thread();78EventRequestManager erm = vm().eventRequestManager();7980/*81* Set event requests82*/83StepRequest request = erm.createStepRequest(mainThread,84StepRequest.STEP_LINE,85StepRequest.STEP_OVER);86request.enable();8788/*89* This should not die with ConcurrentModificationException90*/91erm.deleteEventRequests(erm.stepRequests());9293/*94* resume the target listening for events95*/96listenUntilVMDisconnect();9798/*99* deal with results of test100* if anything has called failure("foo") testFailed will be true101*/102if (!testFailed) {103println("DeleteEventRequestsTest: passed");104} else {105throw new Exception("DeleteEventRequestsTest: failed");106}107}108}109110111