/*
* 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 6431735
* @summary Unexpected ClassCastException in ThreadReference.forceEarlyReturn
* @author Jim Holmlund
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g EarlyReturnNegativeTest.java
* @run main EarlyReturnNegativeTest
*/
/*
* This test has a debuggee which calls an instance method
* for each kind of JDI value return type.
*
* The debugger sets breakpoints in all methods. When a breakpoint
* is hit the debugger requests an early return and supplies a new
* return value. The new value is not compatible with the method's
* return type so an InvalidTypeException should be thrown.
*
* Each value is stored in a static var in the debuggee. The debugger
* gets the values from these static vars to pass back to the
* debuggee in forceEarlyReturn.
*
* This test was created out of EarlyReturnTest.java. Not all of the
* debuggee methods are actually used, just the ones needed to test
* for correct operation. I left the others in just in case they come
* in handy in the future.
*/
class EarlyReturnNegativeTarg {
/*
* These are the values that will be used by methods
* returning normally.
*/
public static boolean booleanValue = false;
{
try {
}
}
new EarlyReturnNegativeTarg();
// Used to show which set of tests follows
// These are the instance methods
{ return classLoaderValue; }
{ return threadGroupValue; }
public void i_voidf() {}
s_show("========== Testing instance methods ================");
xx.i_booleanf();
xx.i_intArrayf();
xx.i_objectArrayf();
xx.i_classLoaderf();
xx.i_threadGroupf();
xx.i_nullObjectf();
}
/*
* The debugger will stop at the start of main,
* set breakpoints and then do a resume.
*/
new EarlyReturnNegativeTarg();
}
}
super(args);
}
meee.startTests();
}
}
throw new IllegalArgumentException("Bad method name/signature");
}
return bpr;
}
try {
} catch (InvalidTypeException ex) {
return;
return;
}
}
vm().canForceEarlyReturn()) {
/* There are some incompatible classes of values. In the following,
* we test each combination.
*/
} else {
// just ignore others
return;
}
} else {
}
}
/*
* Get to the top of main()
* to determine targetClass and mainThread
*/
/*
* We set and enable breakpoints on all of the interesting
* methods called by doit(). In the breakpointReached()
* handler we force an early return with a different return
* value.
*
*/
/* Create Value objects to be passed in forceEarlyReturn calls */
/* Here we go. This adds 'this' as a listener so
* that our handlers above will be called.
*/
if (!testFailed) {
} else {
throw new Exception("EarlyReturnNegativeTest: failed");
}
}
}