J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2001 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 4331872 |
| 27 | * @summary erm.deleteEventRequests(erm.breakpointRequests()) throws exception |
| 28 | * |
| 29 | * @author Robert Field |
| 30 | * |
| 31 | * @run build TestScaffold VMConnection TargetListener TargetAdapter |
| 32 | * @run compile -g DeleteEventRequestsTest.java |
| 33 | * @run main DeleteEventRequestsTest |
| 34 | */ |
| 35 | import com.sun.jdi.*; |
| 36 | import com.sun.jdi.event.*; |
| 37 | import com.sun.jdi.request.*; |
| 38 | |
| 39 | import java.util.*; |
| 40 | |
| 41 | /********** target program **********/ |
| 42 | |
| 43 | class DeleteEventRequestsTarg { |
| 44 | public static void main(String[] args){ |
| 45 | System.out.println("Howdy!"); |
| 46 | System.out.println("Goodbye from DeleteEventRequestsTarg!"); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /********** test program **********/ |
| 51 | |
| 52 | public class DeleteEventRequestsTest extends TestScaffold { |
| 53 | ReferenceType targetClass; |
| 54 | ThreadReference mainThread; |
| 55 | |
| 56 | DeleteEventRequestsTest (String args[]) { |
| 57 | super(args); |
| 58 | } |
| 59 | |
| 60 | public static void main(String[] args) throws Exception { |
| 61 | new DeleteEventRequestsTest(args).startTests(); |
| 62 | } |
| 63 | |
| 64 | /********** event handlers **********/ |
| 65 | |
| 66 | public void stepCompleted(StepEvent event) { |
| 67 | failure("Got StepEvent which was deleted"); |
| 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("DeleteEventRequestsTarg"); |
| 78 | targetClass = bpe.location().declaringType(); |
| 79 | mainThread = bpe.thread(); |
| 80 | EventRequestManager erm = vm().eventRequestManager(); |
| 81 | |
| 82 | /* |
| 83 | * Set event requests |
| 84 | */ |
| 85 | StepRequest request = erm.createStepRequest(mainThread, |
| 86 | StepRequest.STEP_LINE, |
| 87 | StepRequest.STEP_OVER); |
| 88 | request.enable(); |
| 89 | |
| 90 | /* |
| 91 | * This should not die with ConcurrentModificationException |
| 92 | */ |
| 93 | erm.deleteEventRequests(erm.stepRequests()); |
| 94 | |
| 95 | /* |
| 96 | * resume the target listening for events |
| 97 | */ |
| 98 | listenUntilVMDisconnect(); |
| 99 | |
| 100 | /* |
| 101 | * deal with results of test |
| 102 | * if anything has called failure("foo") testFailed will be true |
| 103 | */ |
| 104 | if (!testFailed) { |
| 105 | println("DeleteEventRequestsTest: passed"); |
| 106 | } else { |
| 107 | throw new Exception("DeleteEventRequestsTest: failed"); |
| 108 | } |
| 109 | } |
| 110 | } |