mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8180890: move c.o.testlibrary.jsr292 classes to jdk/test/java/lang/invoke directory
Reviewed-by: rriggs
This commit is contained in:
parent
da6d0e38ee
commit
2bed581331
13 changed files with 622 additions and 524 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -21,7 +21,9 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.Helper;
|
import sun.invoke.util.Wrapper;
|
||||||
|
import test.java.lang.invoke.lib.Helper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
|
@ -31,13 +33,12 @@ import java.lang.invoke.WrongMethodTypeException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import sun.invoke.util.Wrapper;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8060483 8066746
|
* @bug 8060483 8066746
|
||||||
* @key randomness
|
* @key randomness
|
||||||
* @library /lib/testlibrary /lib/testlibrary/jsr292
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @modules java.base/sun.invoke.util
|
* @modules java.base/sun.invoke.util
|
||||||
* @summary unit tests for MethodHandles.explicitCastArguments()
|
* @summary unit tests for MethodHandles.explicitCastArguments()
|
||||||
* @run main ExplicitCastArgumentsTest
|
* @run main ExplicitCastArgumentsTest
|
||||||
|
@ -249,21 +250,27 @@ public class ExplicitCastArgumentsTest {
|
||||||
for (Class parent : parents) {
|
for (Class parent : parents) {
|
||||||
for (int j = 0; j < children.length; j++) {
|
for (int j = 0; j < children.length; j++) {
|
||||||
// Child type to parent type non-null conversion, shoud succeed
|
// Child type to parent type non-null conversion, shoud succeed
|
||||||
testConversion(mode, children[j], parent, childInst[j], childInst[j], false, null);
|
testConversion(mode, children[j], parent, childInst[j],
|
||||||
|
childInst[j], false, null);
|
||||||
// Child type to parent type null conversion, shoud succeed
|
// Child type to parent type null conversion, shoud succeed
|
||||||
testConversion(mode, children[j], parent, null, null, false, null);
|
testConversion(mode, children[j], parent, null,
|
||||||
|
null, false, null);
|
||||||
// Parent type to child type non-null conversion with parent
|
// Parent type to child type non-null conversion with parent
|
||||||
// type instance, should fail
|
// type instance, should fail
|
||||||
testConversion(mode, parent, children[j], testSuperObj, null, true, ClassCastException.class);
|
testConversion(mode, parent, children[j], testSuperObj,
|
||||||
|
null, true, ClassCastException.class);
|
||||||
// Parent type to child type non-null conversion with child
|
// Parent type to child type non-null conversion with child
|
||||||
// type instance, should succeed
|
// type instance, should succeed
|
||||||
testConversion(mode, parent, children[j], childInst[j], childInst[j], false, null);
|
testConversion(mode, parent, children[j], childInst[j],
|
||||||
|
childInst[j], false, null);
|
||||||
// Parent type to child type null conversion, should succeed
|
// Parent type to child type null conversion, should succeed
|
||||||
testConversion(mode, parent, children[j], null, null, false, null);
|
testConversion(mode, parent, children[j], null,
|
||||||
|
null, false, null);
|
||||||
}
|
}
|
||||||
// Parent type to child type non-null conversion with sibling
|
// Parent type to child type non-null conversion with sibling
|
||||||
// type instance, should fail
|
// type instance, should fail
|
||||||
testConversion(mode, parent, testSubClass1, testObj02, null, true, ClassCastException.class);
|
testConversion(mode, parent, testSubClass1, testObj02,
|
||||||
|
null, true, ClassCastException.class);
|
||||||
}
|
}
|
||||||
// Sibling type non-null conversion, should fail
|
// Sibling type non-null conversion, should fail
|
||||||
testConversion(mode, testSubClass1,
|
testConversion(mode, testSubClass1,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,11 +28,15 @@
|
||||||
* @ignore 8078602
|
* @ignore 8078602
|
||||||
* @summary Test verifies that lambda forms are garbage collected
|
* @summary Test verifies that lambda forms are garbage collected
|
||||||
* @author kshefov
|
* @author kshefov
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @build TestMethods
|
* @build TestMethods
|
||||||
* @build LambdaFormTestCase
|
* @build LambdaFormTestCase
|
||||||
* @build LFGarbageCollectedTest
|
* @build LFGarbageCollectedTest
|
||||||
* @run main/othervm -Xmx64m -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+HeapDumpOnOutOfMemoryError -DHEAP_DUMP=false LFGarbageCollectedTest
|
* @run main/othervm -Xmx64m
|
||||||
|
* -XX:SoftRefLRUPolicyMSPerMB=0
|
||||||
|
* -XX:+HeapDumpOnOutOfMemoryError
|
||||||
|
* -DHEAP_DUMP=false
|
||||||
|
* LFGarbageCollectedTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* @key randomness
|
* @key randomness
|
||||||
* @summary Test verifies that lambda forms are cached when run with multiple threads
|
* @summary Test verifies that lambda forms are cached when run with multiple threads
|
||||||
* @author kshefov
|
* @author kshefov
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @modules java.base/java.lang.invoke:open
|
* @modules java.base/java.lang.invoke:open
|
||||||
* java.base/java.lang.ref:open
|
* java.base/java.lang.ref:open
|
||||||
* java.management
|
* java.management
|
||||||
|
@ -38,16 +38,16 @@
|
||||||
* @run main/othervm LFMultiThreadCachingTest
|
* @run main/othervm LFMultiThreadCachingTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.BrokenBarrierException;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.CyclicBarrier;
|
import java.util.concurrent.CyclicBarrier;
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple threaded lambda forms caching test class.
|
* Multiple threaded lambda forms caching test class.
|
||||||
|
@ -57,13 +57,16 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase {
|
||||||
private static final TestMethods.Kind[] KINDS;
|
private static final TestMethods.Kind[] KINDS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
|
EnumSet<TestMethods.Kind> set
|
||||||
|
= EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
|
||||||
KINDS = set.toArray(new TestMethods.Kind[set.size()]);
|
KINDS = set.toArray(new TestMethods.Kind[set.size()]);
|
||||||
if (KINDS.length < 2) {
|
if (KINDS.length < 2) {
|
||||||
throw new Error("TESTBUG: KINDS.length[" + KINDS.length + "] should be at least 2");
|
throw new Error("TESTBUG: KINDS.length[" + KINDS.length
|
||||||
|
+ "] should be at least 2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final int CORES = Math.max(KINDS.length, Runtime.getRuntime().availableProcessors());
|
private static final int CORES
|
||||||
|
= Math.max(KINDS.length, Runtime.getRuntime().availableProcessors());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor a for multiple threaded lambda forms caching test case.
|
* Constructor a for multiple threaded lambda forms caching test case.
|
||||||
|
@ -144,6 +147,7 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase {
|
||||||
* @param args Accepts no arguments.
|
* @param args Accepts no arguments.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LambdaFormTestCase.runTests(LFMultiThreadCachingTest::new, EnumSet.allOf(TestMethods.class));
|
LambdaFormTestCase.runTests(LFMultiThreadCachingTest::new,
|
||||||
|
EnumSet.allOf(TestMethods.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* @key randomness
|
* @key randomness
|
||||||
* @summary Test verifies that lambda forms are cached when run with single thread
|
* @summary Test verifies that lambda forms are cached when run with single thread
|
||||||
* @author kshefov
|
* @author kshefov
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @modules java.base/java.lang.ref:open
|
* @modules java.base/java.lang.ref:open
|
||||||
* java.base/java.lang.invoke:open
|
* java.base/java.lang.invoke:open
|
||||||
* java.management
|
* java.management
|
||||||
|
@ -77,6 +77,7 @@ public final class LFSingleThreadCachingTest extends LFCachingTestCase {
|
||||||
* @param args Accepts no arguments.
|
* @param args Accepts no arguments.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LambdaFormTestCase.runTests(LFSingleThreadCachingTest::new, EnumSet.allOf(TestMethods.class));
|
LambdaFormTestCase.runTests(LFSingleThreadCachingTest::new,
|
||||||
|
EnumSet.allOf(TestMethods.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -21,8 +21,11 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.Helper;
|
import jdk.testlibrary.TimeLimitedRunner;
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
import jdk.testlibrary.Utils;
|
||||||
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
|
import test.java.lang.invoke.lib.Helper;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.management.GarbageCollectorMXBean;
|
import java.lang.management.GarbageCollectorMXBean;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
@ -32,8 +35,6 @@ import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import jdk.testlibrary.Utils;
|
|
||||||
import jdk.testlibrary.TimeLimitedRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lambda forms caching test case class. Contains all necessary test routines to
|
* Lambda forms caching test case class. Contains all necessary test routines to
|
||||||
|
@ -44,7 +45,8 @@ import jdk.testlibrary.TimeLimitedRunner;
|
||||||
*/
|
*/
|
||||||
public abstract class LambdaFormTestCase {
|
public abstract class LambdaFormTestCase {
|
||||||
|
|
||||||
private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
|
private static final long TIMEOUT = Helper.IS_THOROUGH ?
|
||||||
|
0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is
|
* Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is
|
||||||
|
@ -92,7 +94,8 @@ public abstract class LambdaFormTestCase {
|
||||||
long failCounter;
|
long failCounter;
|
||||||
boolean passed;
|
boolean passed;
|
||||||
|
|
||||||
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
|
TestRun(Function<TestMethods, LambdaFormTestCase> ctor,
|
||||||
|
Collection<TestMethods> testMethods) {
|
||||||
this.ctor = ctor;
|
this.ctor = ctor;
|
||||||
this.testMethods = testMethods;
|
this.testMethods = testMethods;
|
||||||
long testCaseNum = testMethods.size();
|
long testCaseNum = testMethods.size();
|
||||||
|
@ -175,10 +178,12 @@ public abstract class LambdaFormTestCase {
|
||||||
* object.
|
* object.
|
||||||
* @param testMethods list of test methods
|
* @param testMethods list of test methods
|
||||||
*/
|
*/
|
||||||
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
|
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor,
|
||||||
|
Collection<TestMethods> testMethods) {
|
||||||
LambdaFormTestCase.TestRun run
|
LambdaFormTestCase.TestRun run
|
||||||
= new LambdaFormTestCase.TestRun(ctor, testMethods);
|
= new LambdaFormTestCase.TestRun(ctor, testMethods);
|
||||||
TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
|
TimeLimitedRunner runner
|
||||||
|
= new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
|
||||||
try {
|
try {
|
||||||
runner.call();
|
runner.call();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -21,7 +21,8 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.Helper;
|
import test.java.lang.invoke.lib.Helper;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
|
@ -41,462 +42,472 @@ import java.util.Map;
|
||||||
public enum TestMethods {
|
public enum TestMethods {
|
||||||
|
|
||||||
FOLD_ARGUMENTS("foldArguments") {
|
FOLD_ARGUMENTS("foldArguments") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("modifierMHArgNum", modifierMHArgNum);
|
data.put("modifierMHArgNum", modifierMHArgNum);
|
||||||
Class<?> combinerReturnType;
|
Class<?> combinerReturnType;
|
||||||
if (realArity == 0) {
|
if (realArity == 0) {
|
||||||
combinerReturnType = void.class;
|
combinerReturnType = void.class;
|
||||||
} else {
|
} else {
|
||||||
combinerReturnType = Helper.RNG.nextBoolean() ? void.class : mtTarget.parameterType(0);
|
combinerReturnType = Helper.RNG.nextBoolean() ?
|
||||||
}
|
void.class : mtTarget.parameterType(0);
|
||||||
data.put("combinerReturnType", combinerReturnType);
|
}
|
||||||
return data;
|
data.put("combinerReturnType", combinerReturnType);
|
||||||
}
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
Class<?> combinerReturnType = (Class) data.get("combinerReturnType");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
Class<?> combinerReturnType = (Class) data.get("combinerReturnType");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
Class<?> rType = mtTarget.returnType();
|
mtTarget.parameterList(), kind);
|
||||||
int combListStart = (combinerReturnType == void.class) ? 0 : 1;
|
Class<?> rType = mtTarget.returnType();
|
||||||
if (modifierMHArgNum < combListStart) {
|
int combListStart = (combinerReturnType == void.class) ? 0 : 1;
|
||||||
modifierMHArgNum = combListStart;
|
if (modifierMHArgNum < combListStart) {
|
||||||
}
|
modifierMHArgNum = combListStart;
|
||||||
MethodHandle combiner = TestMethods.methodHandleGenerator(combinerReturnType,
|
}
|
||||||
mtTarget.parameterList().subList(combListStart,
|
MethodHandle combiner = TestMethods.methodHandleGenerator(combinerReturnType,
|
||||||
modifierMHArgNum), kind);
|
mtTarget.parameterList().subList(combListStart,
|
||||||
return MethodHandles.foldArguments(target, combiner);
|
modifierMHArgNum), kind);
|
||||||
}
|
return MethodHandles.foldArguments(target, combiner);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
DROP_ARGUMENTS("dropArguments") {
|
DROP_ARGUMENTS("dropArguments") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int dropArgsPos = Helper.RNG.nextInt(realArity + 1);
|
int dropArgsPos = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("dropArgsPos", dropArgsPos);
|
data.put("dropArgsPos", dropArgsPos);
|
||||||
MethodType mtDropArgs = TestMethods.randomMethodTypeGenerator(
|
MethodType mtDropArgs = TestMethods.randomMethodTypeGenerator(
|
||||||
Helper.RNG.nextInt(super.maxArity - realArity));
|
Helper.RNG.nextInt(super.maxArity - realArity));
|
||||||
data.put("mtDropArgs", mtDropArgs);
|
data.put("mtDropArgs", mtDropArgs);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtDropArgs = (MethodType) data.get("mtDropArgs");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int dropArgsPos = (int) data.get("dropArgsPos");
|
MethodType mtDropArgs = (MethodType) data.get("mtDropArgs");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
int dropArgsPos = (int) data.get("dropArgsPos");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
int mtTgtSlotsCount = TestMethods.argSlotsCount(mtTarget);
|
mtTarget.parameterList(), kind);
|
||||||
int mtDASlotsCount = TestMethods.argSlotsCount(mtDropArgs);
|
int mtTgtSlotsCount = TestMethods.argSlotsCount(mtTarget);
|
||||||
List<Class<?>> fakeParList;
|
int mtDASlotsCount = TestMethods.argSlotsCount(mtDropArgs);
|
||||||
if (mtTgtSlotsCount + mtDASlotsCount > super.maxArity - 1) {
|
List<Class<?>> fakeParList;
|
||||||
fakeParList = TestMethods.reduceArgListToSlotsCount(mtDropArgs.parameterList(),
|
if (mtTgtSlotsCount + mtDASlotsCount > super.maxArity - 1) {
|
||||||
super.maxArity - mtTgtSlotsCount - 1);
|
fakeParList = TestMethods.reduceArgListToSlotsCount(mtDropArgs.parameterList(),
|
||||||
} else {
|
super.maxArity - mtTgtSlotsCount - 1);
|
||||||
fakeParList = mtDropArgs.parameterList();
|
} else {
|
||||||
}
|
fakeParList = mtDropArgs.parameterList();
|
||||||
return MethodHandles.dropArguments(target, dropArgsPos, fakeParList);
|
}
|
||||||
}
|
return MethodHandles.dropArguments(target, dropArgsPos, fakeParList);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
EXPLICIT_CAST_ARGUMENTS("explicitCastArguments", Helper.MAX_ARITY / 2) {
|
EXPLICIT_CAST_ARGUMENTS("explicitCastArguments", Helper.MAX_ARITY / 2) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
MethodType mtExcplCastArgs = TestMethods.randomMethodTypeGenerator(realArity);
|
MethodType mtExcplCastArgs = TestMethods.randomMethodTypeGenerator(realArity);
|
||||||
if (mtTarget.returnType() == void.class) {
|
if (mtTarget.returnType() == void.class) {
|
||||||
mtExcplCastArgs = MethodType.methodType(void.class,
|
mtExcplCastArgs = MethodType.methodType(void.class,
|
||||||
mtExcplCastArgs.parameterArray());
|
mtExcplCastArgs.parameterArray());
|
||||||
}
|
}
|
||||||
if (mtExcplCastArgs.returnType() == void.class) {
|
if (mtExcplCastArgs.returnType() == void.class) {
|
||||||
mtExcplCastArgs = MethodType.methodType(mtTarget.returnType(),
|
mtExcplCastArgs = MethodType.methodType(mtTarget.returnType(),
|
||||||
mtExcplCastArgs.parameterArray());
|
mtExcplCastArgs.parameterArray());
|
||||||
}
|
}
|
||||||
data.put("mtExcplCastArgs", mtExcplCastArgs);
|
data.put("mtExcplCastArgs", mtExcplCastArgs);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtExcplCastArgs = (MethodType) data.get("mtExcplCastArgs");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
MethodType mtExcplCastArgs = (MethodType) data.get("mtExcplCastArgs");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
return MethodHandles.explicitCastArguments(target, mtExcplCastArgs);
|
mtTarget.parameterList(), kind);
|
||||||
}
|
return MethodHandles.explicitCastArguments(target, mtExcplCastArgs);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
FILTER_ARGUMENTS("filterArguments", Helper.MAX_ARITY / 2) {
|
FILTER_ARGUMENTS("filterArguments", Helper.MAX_ARITY / 2) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
|
int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("filterArgsPos", filterArgsPos);
|
data.put("filterArgsPos", filterArgsPos);
|
||||||
int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
|
int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
|
||||||
data.put("filtersArgsArrayLength", filtersArgsArrayLength);
|
data.put("filtersArgsArrayLength", filtersArgsArrayLength);
|
||||||
MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
|
MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
|
||||||
data.put("mtFilter", mtFilter);
|
data.put("mtFilter", mtFilter);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int filterArgsPos = (int) data.get("filterArgsPos");
|
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
||||||
int filtersArgsArrayLength = (int) data.get("filtersArgsArrayLength");
|
int filterArgsPos = (int) data.get("filterArgsPos");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
int filtersArgsArrayLength = (int) data.get("filtersArgsArrayLength");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
MethodHandle[] filters = new MethodHandle[filtersArgsArrayLength];
|
mtTarget.parameterList(), kind);
|
||||||
for (int i = 0; i < filtersArgsArrayLength; i++) {
|
MethodHandle[] filters = new MethodHandle[filtersArgsArrayLength];
|
||||||
filters[i] = TestMethods.filterGenerator(mtFilter.parameterType(i),
|
for (int i = 0; i < filtersArgsArrayLength; i++) {
|
||||||
mtTarget.parameterType(filterArgsPos + i), kind);
|
filters[i] = TestMethods.filterGenerator(mtFilter.parameterType(i),
|
||||||
}
|
mtTarget.parameterType(filterArgsPos + i), kind);
|
||||||
return MethodHandles.filterArguments(target, filterArgsPos, filters);
|
}
|
||||||
}
|
return MethodHandles.filterArguments(target, filterArgsPos, filters);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
FILTER_RETURN_VALUE("filterReturnValue") {
|
FILTER_RETURN_VALUE("filterReturnValue") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
|
int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
|
||||||
int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
|
int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
|
||||||
MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
|
MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
|
||||||
data.put("mtFilter", mtFilter);
|
data.put("mtFilter", mtFilter);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
MethodHandle filter = TestMethods.filterGenerator(mtTarget.returnType(),
|
mtTarget.parameterList(), kind);
|
||||||
mtFilter.returnType(), kind);
|
MethodHandle filter = TestMethods.filterGenerator(mtTarget.returnType(),
|
||||||
return MethodHandles.filterReturnValue(target, filter);
|
mtFilter.returnType(), kind);
|
||||||
}
|
return MethodHandles.filterReturnValue(target, filter);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
INSERT_ARGUMENTS("insertArguments", Helper.MAX_ARITY - 3) {
|
INSERT_ARGUMENTS("insertArguments", Helper.MAX_ARITY - 3) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int insertArgsPos = Helper.RNG.nextInt(realArity + 1);
|
int insertArgsPos = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("insertArgsPos", insertArgsPos);
|
data.put("insertArgsPos", insertArgsPos);
|
||||||
int insertArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - insertArgsPos);
|
int insertArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - insertArgsPos);
|
||||||
MethodType mtInsertArgs = MethodType.methodType(void.class, mtTarget.parameterList()
|
MethodType mtInsertArgs = MethodType.methodType(void.class, mtTarget.parameterList()
|
||||||
.subList(insertArgsPos, insertArgsPos + insertArgsArrayLength));
|
.subList(insertArgsPos, insertArgsPos + insertArgsArrayLength));
|
||||||
data.put("mtInsertArgs", mtInsertArgs);
|
data.put("mtInsertArgs", mtInsertArgs);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtInsertArgs = (MethodType) data.get("mtInsertArgs");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int insertArgsPos = (int) data.get("insertArgsPos");
|
MethodType mtInsertArgs = (MethodType) data.get("mtInsertArgs");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
int insertArgsPos = (int) data.get("insertArgsPos");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
Object[] insertList = Helper.randomArgs(mtInsertArgs.parameterList());
|
mtTarget.parameterList(), kind);
|
||||||
return MethodHandles.insertArguments(target, insertArgsPos, insertList);
|
Object[] insertList = Helper.randomArgs(mtInsertArgs.parameterList());
|
||||||
}
|
return MethodHandles.insertArguments(target, insertArgsPos, insertList);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
PERMUTE_ARGUMENTS("permuteArguments", Helper.MAX_ARITY / 2) {
|
PERMUTE_ARGUMENTS("permuteArguments", Helper.MAX_ARITY / 2) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int[] permuteArgsReorderArray = new int[realArity];
|
int[] permuteArgsReorderArray = new int[realArity];
|
||||||
int mtPermuteArgsNum = Helper.RNG.nextInt(Helper.MAX_ARITY);
|
int mtPermuteArgsNum = Helper.RNG.nextInt(Helper.MAX_ARITY);
|
||||||
mtPermuteArgsNum = mtPermuteArgsNum == 0 ? 1 : mtPermuteArgsNum;
|
mtPermuteArgsNum = mtPermuteArgsNum == 0 ? 1 : mtPermuteArgsNum;
|
||||||
MethodType mtPermuteArgs = TestMethods.randomMethodTypeGenerator(mtPermuteArgsNum);
|
MethodType mtPermuteArgs = TestMethods.randomMethodTypeGenerator(mtPermuteArgsNum);
|
||||||
mtTarget = mtTarget.changeReturnType(mtPermuteArgs.returnType());
|
mtTarget = mtTarget.changeReturnType(mtPermuteArgs.returnType());
|
||||||
for (int i = 0; i < realArity; i++) {
|
for (int i = 0; i < realArity; i++) {
|
||||||
int mtPermuteArgsParNum = Helper.RNG.nextInt(mtPermuteArgs.parameterCount());
|
int mtPermuteArgsParNum = Helper.RNG.nextInt(mtPermuteArgs.parameterCount());
|
||||||
permuteArgsReorderArray[i] = mtPermuteArgsParNum;
|
permuteArgsReorderArray[i] = mtPermuteArgsParNum;
|
||||||
mtTarget = mtTarget.changeParameterType(
|
mtTarget = mtTarget.changeParameterType(
|
||||||
i, mtPermuteArgs.parameterType(mtPermuteArgsParNum));
|
i, mtPermuteArgs.parameterType(mtPermuteArgsParNum));
|
||||||
}
|
}
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
data.put("permuteArgsReorderArray", permuteArgsReorderArray);
|
data.put("permuteArgsReorderArray", permuteArgsReorderArray);
|
||||||
data.put("mtPermuteArgs", mtPermuteArgs);
|
data.put("mtPermuteArgs", mtPermuteArgs);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtPermuteArgs = (MethodType) data.get("mtPermuteArgs");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int[] permuteArgsReorderArray = (int[]) data.get("permuteArgsReorderArray");
|
MethodType mtPermuteArgs = (MethodType) data.get("mtPermuteArgs");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
int[] permuteArgsReorderArray = (int[]) data.get("permuteArgsReorderArray");
|
||||||
mtTarget.parameterList(), kind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
return MethodHandles.permuteArguments(target, mtPermuteArgs, permuteArgsReorderArray);
|
mtTarget.parameterList(), kind);
|
||||||
}
|
return MethodHandles.permuteArguments(target, mtPermuteArgs, permuteArgsReorderArray);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
THROW_EXCEPTION("throwException") {
|
THROW_EXCEPTION("throwException") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
Class<?> rType = mtTarget.returnType();
|
Class<?> rType = mtTarget.returnType();
|
||||||
return MethodHandles.throwException(rType, Exception.class
|
return MethodHandles.throwException(rType, Exception.class
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GUARD_WITH_TEST("guardWithTest") {
|
GUARD_WITH_TEST("guardWithTest") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("modifierMHArgNum", modifierMHArgNum);
|
data.put("modifierMHArgNum", modifierMHArgNum);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
TestMethods.Kind targetKind;
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
TestMethods.Kind fallbackKind;
|
TestMethods.Kind targetKind;
|
||||||
if (kind.equals(TestMethods.Kind.ONE)) {
|
TestMethods.Kind fallbackKind;
|
||||||
targetKind = TestMethods.Kind.ONE;
|
if (kind.equals(TestMethods.Kind.ONE)) {
|
||||||
fallbackKind = TestMethods.Kind.TWO;
|
targetKind = TestMethods.Kind.ONE;
|
||||||
} else {
|
fallbackKind = TestMethods.Kind.TWO;
|
||||||
targetKind = TestMethods.Kind.TWO;
|
} else {
|
||||||
fallbackKind = TestMethods.Kind.ONE;
|
targetKind = TestMethods.Kind.TWO;
|
||||||
}
|
fallbackKind = TestMethods.Kind.ONE;
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
}
|
||||||
mtTarget.parameterList(), targetKind);
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
MethodHandle fallback = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
mtTarget.parameterList(), targetKind);
|
||||||
mtTarget.parameterList(), fallbackKind);
|
MethodHandle fallback = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
MethodHandle test = TestMethods.methodHandleGenerator(boolean.class,
|
mtTarget.parameterList(), fallbackKind);
|
||||||
mtTarget.parameterList().subList(0, modifierMHArgNum), kind);
|
MethodHandle test = TestMethods.methodHandleGenerator(boolean.class,
|
||||||
return MethodHandles.guardWithTest(test, target, fallback);
|
mtTarget.parameterList().subList(0, modifierMHArgNum), kind);
|
||||||
}
|
return MethodHandles.guardWithTest(test, target, fallback);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
CATCH_EXCEPTION("catchException") {
|
CATCH_EXCEPTION("catchException") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("modifierMHArgNum", modifierMHArgNum);
|
data.put("modifierMHArgNum", modifierMHArgNum);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodHandle target;
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
if (kind.equals(TestMethods.Kind.ONE)) {
|
MethodHandle target;
|
||||||
target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
if (kind.equals(TestMethods.Kind.ONE)) {
|
||||||
mtTarget.parameterList(), TestMethods.Kind.ONE);
|
target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
} else {
|
mtTarget.parameterList(), TestMethods.Kind.ONE);
|
||||||
target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
} else {
|
||||||
mtTarget.parameterList(), TestMethods.Kind.EXCEPT);
|
target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
}
|
mtTarget.parameterList(), TestMethods.Kind.EXCEPT);
|
||||||
List<Class<?>> handlerParamList = new ArrayList<>(mtTarget.parameterCount() + 1);
|
}
|
||||||
handlerParamList.add(Exception.class);
|
List<Class<?>> handlerParamList = new ArrayList<>(mtTarget.parameterCount() + 1);
|
||||||
handlerParamList.addAll(mtTarget.parameterList().subList(0, modifierMHArgNum));
|
handlerParamList.add(Exception.class);
|
||||||
MethodHandle handler = TestMethods.methodHandleGenerator(
|
handlerParamList.addAll(mtTarget.parameterList().subList(0, modifierMHArgNum));
|
||||||
mtTarget.returnType(), handlerParamList, TestMethods.Kind.TWO);
|
MethodHandle handler = TestMethods.methodHandleGenerator(
|
||||||
return MethodHandles.catchException(target, Exception.class, handler);
|
mtTarget.returnType(), handlerParamList, TestMethods.Kind.TWO);
|
||||||
}
|
return MethodHandles.catchException(target, Exception.class, handler);
|
||||||
},
|
}
|
||||||
|
},
|
||||||
INVOKER("invoker", Helper.MAX_ARITY - 1) {
|
INVOKER("invoker", Helper.MAX_ARITY - 1) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
return MethodHandles.invoker(mtTarget);
|
return MethodHandles.invoker(mtTarget);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EXACT_INVOKER("exactInvoker", Helper.MAX_ARITY - 1) {
|
EXACT_INVOKER("exactInvoker", Helper.MAX_ARITY - 1) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
return MethodHandles.exactInvoker(mtTarget);
|
return MethodHandles.exactInvoker(mtTarget);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SPREAD_INVOKER("spreadInvoker", Helper.MAX_ARITY - 1) {
|
SPREAD_INVOKER("spreadInvoker", Helper.MAX_ARITY - 1) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
// Arity after reducing because of long and double take 2 slots.
|
// Arity after reducing because of long and double take 2 slots.
|
||||||
int realArity = mtTarget.parameterCount();
|
int realArity = mtTarget.parameterCount();
|
||||||
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
|
||||||
data.put("modifierMHArgNum", modifierMHArgNum);
|
data.put("modifierMHArgNum", modifierMHArgNum);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
return MethodHandles.spreadInvoker(mtTarget, modifierMHArgNum);
|
return MethodHandles.spreadInvoker(mtTarget, modifierMHArgNum);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ARRAY_ELEMENT_GETTER("arrayElementGetter") {
|
ARRAY_ELEMENT_GETTER("arrayElementGetter") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
Class<?> rType = mtTarget.returnType();
|
Class<?> rType = mtTarget.returnType();
|
||||||
if (rType == void.class) {
|
if (rType == void.class) {
|
||||||
rType = Object.class;
|
rType = Object.class;
|
||||||
}
|
}
|
||||||
return MethodHandles.arrayElementGetter(Array.newInstance(rType, 2).getClass());
|
return MethodHandles.arrayElementGetter(Array.newInstance(rType, 2).getClass());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ARRAY_ELEMENT_SETTER("arrayElementSetter") {
|
ARRAY_ELEMENT_SETTER("arrayElementSetter") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
Class<?> rType = mtTarget.returnType();
|
Class<?> rType = mtTarget.returnType();
|
||||||
if (rType == void.class) {
|
if (rType == void.class) {
|
||||||
rType = Object.class;
|
rType = Object.class;
|
||||||
}
|
}
|
||||||
return MethodHandles.arrayElementSetter(Array.newInstance(rType, 2).getClass());
|
return MethodHandles.arrayElementSetter(Array.newInstance(rType, 2).getClass());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CONSTANT("constant") {
|
CONSTANT("constant") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
Class<?> rType = mtTarget.returnType();
|
Class<?> rType = mtTarget.returnType();
|
||||||
if (rType == void.class) {
|
if (rType == void.class) {
|
||||||
rType = Object.class;
|
rType = Object.class;
|
||||||
}
|
}
|
||||||
if (rType.equals(boolean.class)) {
|
if (rType.equals(boolean.class)) {
|
||||||
// There should be the same return values because for default values there are special "zero" forms
|
// There should be the same return values because for default values there are special "zero" forms
|
||||||
return MethodHandles.constant(rType, true);
|
return MethodHandles.constant(rType, true);
|
||||||
} else {
|
} else {
|
||||||
return MethodHandles.constant(rType, kind.getValue(rType));
|
return MethodHandles.constant(rType, kind.getValue(rType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
IDENTITY("identity") {
|
IDENTITY("identity") {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getTestCaseData() {
|
public Map<String, Object> getTestCaseData() {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
int desiredArity = Helper.RNG.nextInt(super.maxArity);
|
||||||
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
|
||||||
data.put("mtTarget", mtTarget);
|
data.put("mtTarget", mtTarget);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
Class<?> rType = mtTarget.returnType();
|
Class<?> rType = mtTarget.returnType();
|
||||||
if (rType == void.class) {
|
if (rType == void.class) {
|
||||||
rType = Object.class;
|
rType = Object.class;
|
||||||
}
|
}
|
||||||
return MethodHandles.identity(rType);
|
return MethodHandles.identity(rType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method's name.
|
* Test method's name.
|
||||||
|
@ -514,8 +525,10 @@ public enum TestMethods {
|
||||||
this(name, Helper.MAX_ARITY);
|
this(name, Helper.MAX_ARITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
|
protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
|
||||||
throw new UnsupportedOperationException("TESTBUG: getMH method is not implemented for test method " + this);
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"TESTBUG: getMH method is not implemented for test method " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -575,13 +588,15 @@ public enum TestMethods {
|
||||||
return Helper.castToWrapper(value, cl);
|
return Helper.castToWrapper(value, cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodHandle getBasicMH(Class<?> rType) throws NoSuchMethodException, IllegalAccessException {
|
private MethodHandle getBasicMH(Class<?> rType)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodHandle result = null;
|
MethodHandle result = null;
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case ONE:
|
case ONE:
|
||||||
case TWO:
|
case TWO:
|
||||||
if (rType.equals(void.class)) {
|
if (rType.equals(void.class)) {
|
||||||
result = MethodHandles.lookup().findVirtual(Kind.class, "returnVoid", MethodType.methodType(void.class));
|
result = MethodHandles.lookup().findVirtual(Kind.class,
|
||||||
|
"returnVoid", MethodType.methodType(void.class));
|
||||||
result = MethodHandles.insertArguments(result, 0, this);
|
result = MethodHandles.insertArguments(result, 0, this);
|
||||||
} else {
|
} else {
|
||||||
result = MethodHandles.constant(rType, getValue(rType));
|
result = MethodHandles.constant(rType, getValue(rType));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -20,25 +20,30 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package test.java.lang.invoke.MethodHandles;
|
package test.java.lang.invoke.MethodHandles;
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.Helper;
|
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
|
||||||
import jdk.testlibrary.Asserts;
|
import jdk.testlibrary.Asserts;
|
||||||
import jdk.testlibrary.TimeLimitedRunner;
|
import jdk.testlibrary.TimeLimitedRunner;
|
||||||
import jdk.testlibrary.Utils;
|
import jdk.testlibrary.Utils;
|
||||||
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
|
import test.java.lang.invoke.lib.Helper;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary/
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @compile CatchExceptionTest.java
|
* @compile CatchExceptionTest.java
|
||||||
* @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest
|
* @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest
|
||||||
* @key intermittent randomness
|
* @key intermittent randomness
|
||||||
|
@ -68,8 +73,8 @@ public class CatchExceptionTest {
|
||||||
private int dropped;
|
private int dropped;
|
||||||
private MethodHandle thrower;
|
private MethodHandle thrower;
|
||||||
|
|
||||||
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
|
public CatchExceptionTest(TestCase testCase, final boolean isVararg,
|
||||||
final int catchDrops) {
|
final int argsCount, final int catchDrops) {
|
||||||
this.testCase = testCase;
|
this.testCase = testCase;
|
||||||
this.dropped = catchDrops;
|
this.dropped = catchDrops;
|
||||||
MethodHandle thrower = testCase.thrower;
|
MethodHandle thrower = testCase.thrower;
|
||||||
|
@ -353,8 +358,8 @@ class TestCase<T> {
|
||||||
new ClassCastException("testing"),
|
new ClassCastException("testing"),
|
||||||
new java.io.IOException("testing"),
|
new java.io.IOException("testing"),
|
||||||
new LinkageError("testing")};
|
new LinkageError("testing")};
|
||||||
List<Supplier<TestCase>> list = new ArrayList<>(constructors.length *
|
List<Supplier<TestCase>> list = new ArrayList<>(constructors.length
|
||||||
throwables.length * ThrowMode.values().length);
|
* throwables.length * ThrowMode.values().length);
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
for (PartialConstructor f : constructors) {
|
for (PartialConstructor f : constructors) {
|
||||||
for (ThrowMode mode : ThrowMode.values()) {
|
for (ThrowMode mode : ThrowMode.values()) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,23 +23,46 @@
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @summary unit tests for java.lang.invoke.MethodHandles
|
* @summary unit tests for java.lang.invoke.MethodHandles
|
||||||
* @library /lib/testlibrary /lib/testlibrary/jsr292
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @compile MethodHandlesTest.java remote/RemoteExample.java
|
* @compile MethodHandlesTest.java remote/RemoteExample.java
|
||||||
* @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest
|
* @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions
|
||||||
|
* -XX:-VerifyDependencies
|
||||||
|
* -esa
|
||||||
|
* test.java.lang.invoke.MethodHandlesTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package test.java.lang.invoke;
|
package test.java.lang.invoke;
|
||||||
|
|
||||||
import test.java.lang.invoke.remote.RemoteExample;
|
|
||||||
import java.lang.invoke.*;
|
|
||||||
import static java.lang.invoke.MethodType.methodType;
|
|
||||||
import java.lang.invoke.MethodHandles.Lookup;
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
import java.util.*;
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.*;
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
import test.java.lang.invoke.remote.RemoteExample;
|
||||||
|
|
||||||
|
import java.lang.invoke.CallSite;
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodHandleProxies;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodHandles.Lookup;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.lang.invoke.MutableCallSite;
|
||||||
|
import java.lang.invoke.WrongMethodTypeException;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.lang.reflect.UndeclaredThrowableException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Formatter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static java.lang.invoke.MethodType.methodType;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,9 +23,10 @@
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @summary unit tests for method handles which permute their arguments
|
* @summary unit tests for method handles which permute their arguments
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
|
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Examples of manual runs:
|
/* Examples of manual runs:
|
||||||
* java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
|
* java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
|
||||||
* java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest
|
* java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest
|
||||||
|
@ -34,17 +35,23 @@
|
||||||
|
|
||||||
package test.java.lang.invoke;
|
package test.java.lang.invoke;
|
||||||
|
|
||||||
import org.testng.*;
|
import org.testng.annotations.Test;
|
||||||
import org.testng.annotations.*;
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.lang.invoke.WrongMethodTypeException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import java.util.*;
|
import static java.lang.invoke.MethodHandles.Lookup;
|
||||||
import java.lang.reflect.*;
|
import static java.lang.invoke.MethodHandles.lookup;
|
||||||
|
import static java.lang.invoke.MethodHandles.permuteArguments;
|
||||||
import java.lang.invoke.*;
|
import static java.lang.invoke.MethodType.methodType;
|
||||||
import static java.lang.invoke.MethodHandles.*;
|
|
||||||
import static java.lang.invoke.MethodType.*;
|
|
||||||
|
|
||||||
public class PermuteArgsTest {
|
public class PermuteArgsTest {
|
||||||
private static final Class<?> CLASS = PermuteArgsTest.class;
|
private static final Class<?> CLASS = PermuteArgsTest.class;
|
||||||
|
@ -205,7 +212,8 @@ public class PermuteArgsTest {
|
||||||
throw new IllegalArgumentException("cannot convert to type "+mt1+" from "+mh, ex);
|
throw new IllegalArgumentException("cannot convert to type "+mt1+" from "+mh, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static MethodHandle findTestMH(String name, int[] perm) throws ReflectiveOperationException {
|
static MethodHandle findTestMH(String name, int[] perm)
|
||||||
|
throws ReflectiveOperationException {
|
||||||
int arity = perm.length;
|
int arity = perm.length;
|
||||||
Lookup lookup = lookup();
|
Lookup lookup = lookup();
|
||||||
for (Method m : lookup.lookupClass().getDeclaredMethods()) {
|
for (Method m : lookup.lookupClass().getDeclaredMethods()) {
|
||||||
|
@ -259,7 +267,8 @@ public class PermuteArgsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testPermutations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable {
|
static void testPermutations(MethodHandle mh, int[] perm, int start, int end,
|
||||||
|
Set<String> done) throws Throwable {
|
||||||
if (end - start <= 1) return;
|
if (end - start <= 1) return;
|
||||||
for (int j = 0; j <= 1; j++) {
|
for (int j = 0; j <= 1; j++) {
|
||||||
testRotations(mh, perm, start, end, done);
|
testRotations(mh, perm, start, end, done);
|
||||||
|
@ -283,7 +292,8 @@ public class PermuteArgsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testRotations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable {
|
static void testRotations(MethodHandle mh, int[] perm, int start, int end,
|
||||||
|
Set<String> done) throws Throwable {
|
||||||
Object[] args = junkArgs(mh.type().parameterArray());
|
Object[] args = junkArgs(mh.type().parameterArray());
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
if (done.add(Arrays.toString(perm)))
|
if (done.add(Arrays.toString(perm)))
|
||||||
|
@ -292,9 +302,11 @@ public class PermuteArgsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testOnePermutation(MethodHandle mh, int[] perm, Object[] args) throws Throwable {
|
static void testOnePermutation(MethodHandle mh, int[] perm, Object[] args)
|
||||||
|
throws Throwable {
|
||||||
MethodType mt = mh.type();
|
MethodType mt = mh.type();
|
||||||
MethodType pmt = methodType(mt.returnType(), unpermuteArgs(perm, mt.parameterArray(), Class[].class));
|
MethodType pmt = methodType(mt.returnType(),
|
||||||
|
unpermuteArgs(perm, mt.parameterArray(), Class[].class));
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
System.out.println(Arrays.toString(perm));
|
System.out.println(Arrays.toString(perm));
|
||||||
testCases += 1;
|
testCases += 1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -24,14 +24,18 @@
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8019184
|
* @bug 8019184
|
||||||
* @library /lib/testlibrary /lib/testlibrary/jsr292
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @summary MethodHandles.catchException() fails when methods have 8 args + varargs
|
* @summary MethodHandles.catchException() fails when methods have 8 args + varargs
|
||||||
* @run main TestCatchExceptionWithVarargs
|
* @run main TestCatchExceptionWithVarargs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
import java.util.*;
|
|
||||||
import java.lang.invoke.*;
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TestCatchExceptionWithVarargs {
|
public class TestCatchExceptionWithVarargs {
|
||||||
|
|
||||||
|
@ -48,14 +52,16 @@ public class TestCatchExceptionWithVarargs {
|
||||||
|
|
||||||
public static Object target(Object... a) throws Exception {
|
public static Object target(Object... a) throws Exception {
|
||||||
if (a[0] != firstArg) {
|
if (a[0] != firstArg) {
|
||||||
throw new AssertionError("first argument different than expected: " + a[0] + " != " + firstArg);
|
throw new AssertionError("first argument different than expected: "
|
||||||
|
+ a[0] + " != " + firstArg);
|
||||||
}
|
}
|
||||||
throw new MyException();
|
throw new MyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object handler(Object... a) {
|
public static Object handler(Object... a) {
|
||||||
if (a[0] != firstArg) {
|
if (a[0] != firstArg) {
|
||||||
throw new AssertionError("first argument different than expected: " + a[0] + " != " + firstArg);
|
throw new AssertionError("first argument different than expected: "
|
||||||
|
+ a[0] + " != " + firstArg);
|
||||||
}
|
}
|
||||||
return a[0];
|
return a[0];
|
||||||
}
|
}
|
||||||
|
@ -83,20 +89,27 @@ public class TestCatchExceptionWithVarargs {
|
||||||
for (int i = 1; i < MAX_MH_ARITY - 1; i++) {
|
for (int i = 1; i < MAX_MH_ARITY - 1; i++) {
|
||||||
ptypes.add(0, Object.class);
|
ptypes.add(0, Object.class);
|
||||||
|
|
||||||
MethodHandle targetWithArgs = target.asType(MethodType.methodType(Object.class, ptypes));
|
MethodHandle targetWithArgs = target.asType(
|
||||||
MethodHandle handlerWithArgs = handler.asType(MethodType.methodType(Object.class, ptypes));
|
MethodType.methodType(Object.class, ptypes));
|
||||||
handlerWithArgs = MethodHandles.dropArguments(handlerWithArgs, 0, MyException.class);
|
MethodHandle handlerWithArgs = handler.asType(
|
||||||
|
MethodType.methodType(Object.class, ptypes));
|
||||||
|
handlerWithArgs = MethodHandles.dropArguments(
|
||||||
|
handlerWithArgs, 0, MyException.class);
|
||||||
|
|
||||||
MethodHandle gwc1 = MethodHandles.catchException(targetWithArgs, MyException.class, handlerWithArgs);
|
MethodHandle gwc1 = MethodHandles.catchException(
|
||||||
|
targetWithArgs, MyException.class, handlerWithArgs);
|
||||||
|
|
||||||
// The next line throws an IllegalArgumentException if there is a bug.
|
// The next line throws an IllegalArgumentException if there is a bug.
|
||||||
MethodHandle gwc2 = MethodHandles.catchException(gwc1, MyException.class, handlerWithArgs);
|
MethodHandle gwc2 = MethodHandles.catchException(
|
||||||
|
gwc1, MyException.class, handlerWithArgs);
|
||||||
|
|
||||||
// This is only to verify that the method handles can actually be invoked and do the right thing.
|
// This is only to verify that the method handles can actually be invoked and do the right thing.
|
||||||
firstArg = new Object();
|
firstArg = new Object();
|
||||||
Object o = gwc2.asSpreader(Object[].class, ptypes.size() - 1).invoke(firstArg, new Object[i]);
|
Object o = gwc2.asSpreader(Object[].class, ptypes.size() - 1)
|
||||||
|
.invoke(firstArg, new Object[i]);
|
||||||
if (o != firstArg) {
|
if (o != firstArg) {
|
||||||
throw new AssertionError("return value different than expected: " + o + " != " + firstArg);
|
throw new AssertionError("return value different than expected: "
|
||||||
|
+ o + " != " + firstArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -21,20 +21,20 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import sun.invoke.util.Wrapper;
|
||||||
|
import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandleHelper;
|
import java.lang.invoke.MethodHandleHelper;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import sun.invoke.util.Wrapper;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int),
|
* @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int),
|
||||||
* MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int)
|
* MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int)
|
||||||
* @modules java.base/sun.invoke.util
|
* @modules java.base/sun.invoke.util
|
||||||
* @library /lib/testlibrary /lib/testlibrary/jsr292
|
* @library /lib/testlibrary /java/lang/invoke/common
|
||||||
* @compile/module=java.base java/lang/invoke/MethodHandleHelper.java
|
* @compile/module=java.base java/lang/invoke/MethodHandleHelper.java
|
||||||
* @run main/bootclasspath VarargsArrayTest
|
* @run main/bootclasspath VarargsArrayTest
|
||||||
* @run main/bootclasspath/othervm -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250
|
* @run main/bootclasspath/othervm -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250
|
||||||
|
@ -46,9 +46,12 @@ import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
||||||
*/
|
*/
|
||||||
public class VarargsArrayTest {
|
public class VarargsArrayTest {
|
||||||
private static final Class<?> CLASS = VarargsArrayTest.class;
|
private static final Class<?> CLASS = VarargsArrayTest.class;
|
||||||
private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 40);
|
private static final int MAX_ARITY = Integer.getInteger(
|
||||||
private static final int START_ARITY = Integer.getInteger(CLASS.getSimpleName()+".START_ARITY", 0);
|
CLASS.getSimpleName()+".MAX_ARITY", 40);
|
||||||
private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE");
|
private static final int START_ARITY = Integer.getInteger(
|
||||||
|
CLASS.getSimpleName()+".START_ARITY", 0);
|
||||||
|
private static final boolean EXHAUSTIVE = Boolean.getBoolean(
|
||||||
|
CLASS.getSimpleName()+".EXHAUSTIVE");
|
||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test);
|
CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test);
|
||||||
|
@ -211,7 +214,8 @@ public class VarargsArrayTest {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new AssertionError(Arrays.deepToString(arr1) + " != " + Arrays.deepToString(arr2));
|
throw new AssertionError(Arrays.deepToString(arr1)
|
||||||
|
+ " != " + Arrays.deepToString(arr2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertEquals(Object o1, Object o2) {
|
public static void assertEquals(Object o1, Object o2) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -20,7 +20,8 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
package com.oracle.testlibrary.jsr292;
|
|
||||||
|
package test.java.lang.invoke.lib;
|
||||||
|
|
||||||
import jdk.testlibrary.Utils;
|
import jdk.testlibrary.Utils;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -20,7 +20,8 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
package com.oracle.testlibrary.jsr292;
|
|
||||||
|
package test.java.lang.invoke.lib;
|
||||||
|
|
||||||
import jdk.testlibrary.Asserts;
|
import jdk.testlibrary.Asserts;
|
||||||
|
|
||||||
|
@ -28,7 +29,10 @@ import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Helper {
|
public class Helper {
|
||||||
/** Flag for verbose output, true if {@code -Dverbose} specified */
|
/** Flag for verbose output, true if {@code -Dverbose} specified */
|
Loading…
Add table
Add a link
Reference in a new issue