1 /* 2 * Copyright (c) 2000, 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 4315352 27 * @summary disabling EventRequest expired with addCountFilter() throws 28 * InternalException. 29 * @author Robert Field 30 * 31 * @run build TestScaffold VMConnection TargetAdapter TargetListener 32 * @run compile -g CountEvent.java 33 * @run driver CountEvent 34 */ 35 import com.sun.jdi.*; 36 import com.sun.jdi.event.*; 37 import com.sun.jdi.request.*; 38 39 class CountEventTarg { 40 41 static CountEventTarg first = new CountEventTarg(); 42 static CountEventTarg second = new CountEventTarg(); 43 static CountEventTarg third = new CountEventTarg(); 44 main(String args[])45 public static void main(String args[]) { 46 start(); 47 } 48 start()49 static void start() { 50 first.go(); 51 second.go(); 52 third.go(); 53 } 54 go()55 void go() { 56 one(); 57 two(); 58 three(); 59 } 60 one()61 void one() { 62 } 63 two()64 void two() { 65 } 66 three()67 void three() { 68 } 69 } 70 71 public class CountEvent extends TestScaffold { 72 main(String args[])73 public static void main(String args[]) throws Exception { 74 new CountEvent(args).startTests(); 75 } 76 CountEvent(String args[])77 CountEvent(String args[]) throws Exception { 78 super(args); 79 } 80 runTests()81 protected void runTests() throws Exception { 82 83 BreakpointEvent bpe = startToMain("CountEventTarg"); 84 ThreadReference thread = bpe.thread(); 85 86 StepEvent stepEvent = stepIntoLine(thread); 87 88 ReferenceType clazz = thread.frame(0).location().declaringType(); 89 String className = clazz.name(); 90 91 // uses addCountFilter 92 BreakpointEvent bpEvent = resumeTo(className, "go", "()V"); 93 94 bpEvent.request().disable(); 95 System.out.println("About to resume"); 96 resumeToVMDisconnect(); 97 98 if (!testFailed) { 99 println("CountEvent: passed"); 100 } else { 101 throw new Exception("CountEvent: failed"); 102 } 103 } 104 } 105