本文整理汇总了Java中com.oracle.testlibrary.jsr292.Helper.addTrailingArgs方法的典型用法代码示例。如果您正苦于以下问题:Java Helper.addTrailingArgs方法的具体用法?Java Helper.addTrailingArgs怎么用?Java Helper.addTrailingArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.oracle.testlibrary.jsr292.Helper
的用法示例。
在下文中一共展示了Helper.addTrailingArgs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CatchExceptionTest
import com.oracle.testlibrary.jsr292.Helper; //导入方法依赖的package包/类
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
final int catchDrops) {
this.testCase = testCase;
this.dropped = catchDrops;
MethodHandle thrower = testCase.thrower;
int throwerLen = thrower.type().parameterCount();
List<Class<?>> classes;
int extra = Math.max(0, argsCount - throwerLen);
classes = getThrowerParams(isVararg, extra);
this.argsCount = throwerLen + classes.size();
thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
if (isVararg && argsCount > throwerLen) {
MethodType mt = thrower.type();
Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
thrower = thrower.asVarargsCollector(lastParam);
}
this.thrower = thrower;
this.dropped = Math.min(this.argsCount, catchDrops);
catcher = testCase.getCatcher(getCatcherParams());
nargs = Math.max(2, this.argsCount);
}
示例2: testMultipleArgs
import com.oracle.testlibrary.jsr292.Helper; //导入方法依赖的package包/类
/**
* Tests that MHs.eCA method works correctly with MHs with multiple arguments.
* @throws Throwable
*/
public static void testMultipleArgs() throws Throwable {
int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2);
int arityMinus = RNG.nextInt(arity);
int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1;
MethodType mType = Helper.randomMethodTypeGenerator(arity);
MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity);
MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus);
MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus);
Class<?> rType = mType.returnType();
MethodHandle original;
if (rType.equals(void.class)) {
MethodType mt = MethodType.methodType(void.class);
original = MethodHandles.publicLookup()
.findStatic(THIS_CLASS, "retVoid", mt);
} else {
Object rValue = Helper.castToWrapper(1, rType);
original = MethodHandles.constant(rType, rValue);
}
original = Helper.addTrailingArgs(original, arity, mType.parameterList());
MethodHandle target = MethodHandles
.explicitCastArguments(original, mTypeNew);
Object[] parList = Helper.randomArgs(mTypeNew.parameterList());
for (int i = 0; i < parList.length; i++) {
if (parList[i] instanceof String) {
parList[i] = null; //getting rid of Stings produced by randomArgs
}
}
target.invokeWithArguments(parList);
checkForWrongMethodTypeException(original, mTypeNewMinus);
checkForWrongMethodTypeException(original, mTypeNewPlus);
}
示例3: CatchExceptionTest
import com.oracle.testlibrary.jsr292.Helper; //导入方法依赖的package包/类
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
final int catchDrops) {
this.testCase = testCase;
this.dropped = catchDrops;
if (Helper.IS_VERBOSE) {
System.out.printf("CatchException::CatchException(%s, isVararg=%b " +
"argsCount=%d catchDrops=%d)%n",
testCase, isVararg, argsCount, catchDrops
);
}
MethodHandle thrower = testCase.thrower;
int throwerLen = thrower.type().parameterCount();
List<Class<?>> classes;
int extra = Math.max(0, argsCount - throwerLen);
classes = getThrowerParams(isVararg, extra);
this.argsCount = throwerLen + classes.size();
thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes);
if (isVararg && argsCount > throwerLen) {
MethodType mt = thrower.type();
Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1);
thrower = thrower.asVarargsCollector(lastParam);
}
this.thrower = thrower;
this.dropped = Math.min(this.argsCount, catchDrops);
catcher = testCase.getCatcher(getCatcherParams());
nargs = Math.max(2, this.argsCount);
}