mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24: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;
|
||||||
|
@ -55,14 +56,16 @@ public enum TestMethods {
|
||||||
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);
|
data.put("combinerReturnType", combinerReturnType);
|
||||||
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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
Class<?> combinerReturnType = (Class) data.get("combinerReturnType");
|
Class<?> combinerReturnType = (Class) data.get("combinerReturnType");
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
|
@ -97,7 +100,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodType mtDropArgs = (MethodType) data.get("mtDropArgs");
|
MethodType mtDropArgs = (MethodType) data.get("mtDropArgs");
|
||||||
int dropArgsPos = (int) data.get("dropArgsPos");
|
int dropArgsPos = (int) data.get("dropArgsPos");
|
||||||
|
@ -138,7 +142,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodType mtExcplCastArgs = (MethodType) data.get("mtExcplCastArgs");
|
MethodType mtExcplCastArgs = (MethodType) data.get("mtExcplCastArgs");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
|
@ -165,7 +170,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
||||||
int filterArgsPos = (int) data.get("filterArgsPos");
|
int filterArgsPos = (int) data.get("filterArgsPos");
|
||||||
|
@ -197,7 +203,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
MethodType mtFilter = (MethodType) data.get("mtFilter");
|
||||||
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
|
||||||
|
@ -226,7 +233,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodType mtInsertArgs = (MethodType) data.get("mtInsertArgs");
|
MethodType mtInsertArgs = (MethodType) data.get("mtInsertArgs");
|
||||||
int insertArgsPos = (int) data.get("insertArgsPos");
|
int insertArgsPos = (int) data.get("insertArgsPos");
|
||||||
|
@ -262,7 +270,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
MethodType mtPermuteArgs = (MethodType) data.get("mtPermuteArgs");
|
MethodType mtPermuteArgs = (MethodType) data.get("mtPermuteArgs");
|
||||||
int[] permuteArgsReorderArray = (int[]) data.get("permuteArgsReorderArray");
|
int[] permuteArgsReorderArray = (int[]) data.get("permuteArgsReorderArray");
|
||||||
|
@ -304,7 +313,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
TestMethods.Kind targetKind;
|
TestMethods.Kind targetKind;
|
||||||
|
@ -340,7 +350,8 @@ public enum TestMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
MethodType mtTarget = (MethodType) data.get("mtTarget");
|
||||||
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
int modifierMHArgNum = (int) data.get("modifierMHArgNum");
|
||||||
MethodHandle target;
|
MethodHandle target;
|
||||||
|
@ -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