1472N/A * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1472N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Backend hangs when invokeMethod is called from a JDI eventHandler 0N/A * @run build TestScaffold VMConnection TargetListener TargetAdapter 0N/A * @run main InvokeHangTest 0N/A * This debuggee basically runs two threads each of 0N/A * which loop, hitting a bkpt in each iteration. 1080N/A // This is called from the debugger via invokeMethod 0N/A for (
int i =
0; i < n; i++) {
0N/A for (
int j = -
1000*i; j <
1000*i; j++) {
0N/A a = a*(
1 + i/(j +
0.5));
0N/A/********** test program **********/ 0N/A // BreakpointEvent handler 0N/A * This thread will watch for n secs to go by with no 0N/A * calls to this method. 0N/A synchronized(
"abc") {
0N/A * Note that this will most likely never get to 0N/A * the number of times the two bkpt lines in the debuggee 0N/A * are hit because bkpts are lost while they are disabled. 0N/A * The bug occurs when the requests are disabled 0N/A * and then an invoke is done in the event handler. In some cases 0N/A * the other thread has hit a bkpt and the back-end is waiting 0N/A * to send it. When the back-end resumes the debuggee to do the 0N/A * invokeMethod, this 2nd bkpt is released, the debuggee is suspended, including 0N/A * the thread on which the invoke was done (because it is a SUSPEND_ALL bkpt), 0N/A * the bkpt is sent to the front-end, but the client event handler is sitting 0N/A * here waiting for the invoke to finish, so it doesn't get the 2nd bkpt and 0N/A * do the resume for it. Thus, the debuggee is suspended waiting for a resume 0N/A /********** test core **********/ 0N/A * Get to the top of main() 0N/A * to determine targetClass and mainThread 0N/A * Set event requests 0N/A * This thread will be started when we get the first bkpt. 0N/A * (Which we always expect to get). 0N/A * It awakens every n seconds and checks to see if we 0N/A * got any breakpoint events while it was asleep. If not, then 0N/A * we assume the debuggee is hung and fail the test. 0N/A // no bkpt for 'waitTime' msecs 0N/A // This awakens the main thread which is 0N/A // waiting for a VMDisconnect. 0N/A // If the test completes, this occurs. 0N/A * resume the target, listening for events 0N/A * deal with results of test 0N/A * if anything has called failure("foo") testFailed will be true