RicochetTest.java revision 5462
/*
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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
* @summary unit tests for recursive method handles
*/
/*
* @ignore The following test creates an unreasonable number of adapters in -Xcomp mode (7049122)
*/
/**
*
* @author jrose
*/
public class RicochetTest {
} else if (REPEAT == 0) {
} else {
for (int i = 0; i < REPEAT; i++) {
}
}
}
int testRepetition;
testNull();
testBoxLong();
testReturns();
}
@Test
if (!startTest("testNull")) return;
}
@Test
public void testBoxInteger() throws Throwable {
if (!startTest("testBoxInteger")) return;
}
@Test
public void testFilterReturnValue() throws Throwable {
if (!startTest("testFilterReturnValue")) return;
Object res = list8ints.invokeExact(ints[0], ints[1], ints[2], ints[3], ints[4], ints[5], ints[6], ints[7]);
}
@Test
public void testFilterObject() throws Throwable {
if (!startTest("testFilterObject")) return;
}
@Test
public void testBoxLong() throws Throwable {
if (!startTest("testBoxLong")) return;
}
@Test
public void testFilterInteger() throws Throwable {
if (!startTest("testFilterInteger")) return;
}
@Test
public void testIntSpreads() throws Throwable {
if (!startTest("testIntSpreads")) return;
//System.out.println("testIntSpreads "+Arrays.toString(args));
switch (nargs) {
}
}
}
@Test
public void testByteSpreads() throws Throwable {
if (!startTest("testByteSpreads")) return;
//System.out.println("testByteSpreads "+Arrays.toString(args));
switch (nargs) {
}
}
}
@Test
public void testLongSpreads() throws Throwable {
if (!startTest("testLongSpreads")) return;
//System.out.println("testLongSpreads "+Arrays.toString(args));
switch (nargs) {
}
}
}
@Test
public void testIntCollects() throws Throwable {
if (!startTest("testIntCollects")) return;
if (inputs < 0) continue;
for (int i = 0; i < pos; i++)
for (int i = 0; i < collects; i++)
// calculate piecemeal:
//System.out.println("testIntCollects "+Arrays.asList(lister, pos, collector)+" on "+Arrays.toString(args));
//System.out.println(" coll="+coll+" listargs="+Arrays.toString(listargs));
//System.out.println(" expect="+expect);
// now use the combined MH, and test the output:
}
}
}
}
@Test
public void testByteCollects() throws Throwable {
if (!startTest("testByteCollects")) return;
if (inputs < 0) continue;
for (int i = 0; i < pos; i++)
for (int i = 0; i < collects; i++)
// calculate piecemeal:
//System.out.println("testIntCollects "+Arrays.asList(lister, pos, collector)+" on "+Arrays.toString(args));
//System.out.println(" coll="+coll+" listargs="+Arrays.toString(listargs));
//System.out.println(" expect="+expect);
// now use the combined MH, and test the output:
}
}
}
}
private static MethodHandle collectArguments(MethodHandle lister, int pos, Class<?> array, MethodHandle collector) {
//return MethodHandles.collectArguments(lister, pos, collector); //no such animal
return null;
}
private static final Class<?>[] RETURN_TYPES = {
int.class, long.class,
boolean.class, byte.class, char.class, short.class,
float.class, double.class,
void.class,
};
@Test
public void testReturns() throws Throwable {
if (!startTest("testReturns")) return;
// fault injection:
// make a complicated identity function and pass something through it
final int LENGTH = 4;
int[] index = {0};
if (ret != void.class) {
for (int i = 0; i < LENGTH; i++) {
}
}
for (int i = 0; i < LENGTH; i++) {
index[0] = i;
assertEquals(val, x);
// make a return-filter call: x = id(valGetter())
assertEquals(val, x);
// make a filter call: x = id(*,valGetter(),*)
for (int j = 0; j < len; j++) {
if (j == pos) continue;
}
// proj: (Object*, pos: vret, Object*)->ret
assertEquals(val, x);
}
}
// make a fold call:
for (int j = 0; j < len; j++) {
}
// proj: (Object*, pos: vret, Object*)->ret
for (int j = 0; j < fold; j++) {
}
assertEquals(val, x);
}
}
}
}
//System.out.println("faultCount="+faultCount);
}
@Test
public void testRecursion() throws Throwable {
if (!startTest("testRecursion")) return;
final int LIMIT = 10;
for (int i = 0; i < LIMIT; i++) {
}
}
/** Recursive Function Control Block */
private static class RFCB {
final MethodHandle[] fns;
int depth;
@SuppressWarnings("LeakingThisInConstructor")
switch (i % 4) {
}
}
}
depth++;
try {
final int ACTION_COUNT = 11;
case 1:
x = "ST; " + x;
break;
case 2:
x = "GC; " + x;
break;
}
if (isLeaf) {
}
} finally {
depth--;
}
}
}
return res;
}
MethodType t = x.type();
if (t.parameterCount() == 0) {
assertEqualFunctionAt(null, x, y);
return;
}
for (long i = -10; i <= 10; i++) {
assertEqualFunctionAt(i, x, y);
}
} else {
for (int i = -10; i <= 10; i++) {
assertEqualFunctionAt(i, x, y);
}
}
}
private static void assertEqualFunctionAt(Object v, MethodHandle x, MethodHandle y) throws Throwable {
}
}
try {
return ex;
}
}
try {
} catch (ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}
}
}
stress();
int base = 100;
int z = 0;
for (int x : xs) {
}
return z;
}
private static final MethodHandle opI, opI2, opI3, opI4, opI_L, opJ, opJ2, opJ3, opL2, opL, opL2_I, opL_I, opL_J;
static {
}
private static final MethodHandle[] INT_COLLECTORS = {
};
private static final MethodHandle[] BYTE_COLLECTORS = {
};
private static final MethodHandle[] LONG_COLLECTORS = {
};
static {
}
}
private static Object list8longs(long a, long b, long c, long d, long e, long f, long g, long h) {
}
static {
for (int i = listerCount - 1; ; i--) {
INT_LISTERS[i] = lister;
LONG_LISTERS[i] = llister;
if (i == 0) break;
}
}
}
}
return mt;
}
static {
}
// stress modes:
private static /*v*/ int STRESS_COUNT;
private static void stress() {
if (STRESS <= 0) return;
for (int i = 0; i < count; i++) {
}
}
// verbosity:
if (VERBOSITY <= 0) return;
verbose(1, a, b, c, d);
}
if (VERBOSITY <= 0) return;
verbose(1, a, b, c);
}
l.add(x);
}
}
}
return false;
return true;
}
}