/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 4409241 4432820
* @summary Test the bug fix for: MethodExitEvents disappear when Object-Methods are called from main
* @author Tim Bell
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g MethodEntryExitEvents.java
* @run main MethodEntryExitEvents SUSPEND_EVENT_THREAD MethodEntryExitEventsDebugee
* @run main MethodEntryExitEvents SUSPEND_NONE MethodEntryExitEventsDebugee
* @run main MethodEntryExitEvents SUSPEND_ALL MethodEntryExitEventsDebugee
*/
class t2 {
public static void sayHello1(int i, int j) {
sayHello2(i, j);
}
public static void sayHello2(int i, int j) {
sayHello3(i, j);
}
public static void sayHello3(int i, int j) {
sayHello4(i, j);
}
public static void sayHello4(int i, int j) {
sayHello5(i, j);
}
public static void sayHello5(int i, int j) {
if (i < 2) {
sayHello1(++i, j);
} else {
}
}
}
class MethodEntryExitEventsDebugee {
public static void loopComplete () {
/*
* The implementation here is deliberately inefficient
* because the debugger is still watching this method.
*/
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
}
}
for (int j = 0; j < 3; j++) {
}
loopComplete();
}
}
boolean finishedCounting = false;
/*
* Enter main() , then t2.<init>, then sayHello[1,2,3,4,5] 15 times 3 loops,
* then loopComplete()
*/
/*
* Exit t2.<init>, then sayHello[1,2,3,4,5] 15 times 3 loopa
* (event monitoring is cancelled before we exit loopComplete() or main())
*/
/*
* Class patterns for which we don't want events (copied
* from the "Trace.java" example):
*/
"com.sun.*"};
super(args);
}
}
meee.startTests();
}
// Step to the catch
stepReq =
}
}
" event=" + event);
// disable the step and then run to completion
//eventRequestManager().deleteEventRequest(event.request());
}
if (! finishedCounting) {
// We have to count the entry to loopComplete, but
// not the exit
finishedCounting = true;
}
}
}
if (! finishedCounting){
}
}
}
//Pick up the SUSPEND_xxx in first argument
} else {
}
// Skip the test arg
}
try {
/*
* Ask for Exception events
*/
true, // notifyCaught
true);// notifyUncaught
/*
* Ask for method entry events
*/
}
/*
* Ask for method exit events
*/
}
/*
* We are now set up to receive the notifications we want.
* Here we go. This adds 'this' as a listener so
* that our handlers above will be called.
*/
testFailed = true;
}
if ((methodEntryCount != expectedEntryCount) ||
(methodExitCount != expectedExitCount)) {
testFailed = true;
}
if (!testFailed) {
} else {
throw new Exception("MethodEntryExitEvents: failed");
}
}
}