/*
* 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 4195445 6204179
* @summary JDWP, JDI: Add return value to Method Exit Event
* @author Jim Holmlund
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g MethodExitReturnValuesTest.java
* @run main MethodExitReturnValuesTest
*/
/*
* This test has a debuggee which calls a static method
* for each kind of JDI Value, and then an instance method
* for each.
* The debugger turns on MethodExitEvents and checks
* that the right return values are included in the MethodExitEvents.
* Each value is stored in a static var in the debuggee. The debugger
* gets the values from these static vars to check for correct
* return values in the MethodExitEvents.
*/
class MethodExitReturnValuesTarg {
// These are the values that will be returned by the methods
public static boolean booleanValue = false;
{
try {
}
}
new MethodExitReturnValuesTarg();
// arrays to be used in calls to native methods Array.get...(....)
// Used to show which set of tests follows
// These are the static methods
{ return classLoaderValue; }
return threadValue; }
return threadGroupValue; }
public static void s_voidf() {}
// These are the instance methods
{ return classLoaderValue; }
{ return threadGroupValue; }
public void i_voidf() {}
s_show("========== Testing static methods ================");
s_bytef();
s_charf();
s_doublef();
s_floatf();
s_intf();
s_longf();
s_shortf();
s_booleanf();
s_stringf();
s_classf();
s_threadf();
s_intArrayf();
s_objectf();
s_voidf();
s_show("========== Testing instance methods ================");
xx.i_booleanf();
xx.i_intArrayf();
xx.i_classLoaderf();
xx.i_threadGroupf();
xx.i_nullObjectf();
// Prove it works for native methods too
s_show("========== Testing native methods ================");
}
// The debugger will stop at the start of main,
// enable method exit events, and then do
// a resume.
new MethodExitReturnValuesTarg();
}
}
/*
* Class patterns for which we don't want events (copied
* from the "Trace.java" example):
*/
"javax.*",
"sun.*",
"com.sun.*"};
super(args);
}
meee.startTests();
}
// These are the methods that check for correct return values.
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
} else {
successes++;
}
}
// We will check the ivar field which we know contains
// the value of 'stringValue'
} else {
successes++;
}
}
successes++;
}
} else {
successes++;
}
}
// This is the MethodExitEvent handler.
vm().canGetMethodReturnValues()) {
return;
}
// Check native methods
return;
}
return;
}
else {
}
} else {
}
}
/*
* Get to the top of main()
* to determine targetClass and mainThread
*/
/*
* Ask for method exit events
*/
}
//sessionSuspendPolicy = EventRequest.SUSPEND_EVENT_THREAD;
//sessionSuspendPolicy = EventRequest.SUSPEND_NONE;
/*
* 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.
*/
if (successes != expectedSuccesses) {
}
if (!testFailed) {
} else {
throw new Exception("MethodExitReturnValuesTest: failed");
}
}
}