本文整理汇总了Java中java.lang.invoke.MethodType.parameterList方法的典型用法代码示例。如果您正苦于以下问题:Java MethodType.parameterList方法的具体用法?Java MethodType.parameterList怎么用?Java MethodType.parameterList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.invoke.MethodType
的用法示例。
在下文中一共展示了MethodType.parameterList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParameterList
import java.lang.invoke.MethodType; //导入方法依赖的package包/类
/**
* Test of parameterList method, of class MethodType.
*/
@Test
public void testParameterList() {
System.out.println("parameterList");
MethodType instance = mt_viS;
List<Class<?>> expResult = Arrays.asList(ptypes);
List<Class<?>> result = instance.parameterList();
assertEquals(expResult, result);
}
示例2: dropArgumentsToMatchIAEData
import java.lang.invoke.MethodType; //导入方法依赖的package包/类
@DataProvider(name = "dropArgumentsToMatchIAEData")
private Object[][] dropArgumentsToMatchIAEData()
throws NoSuchMethodException, IllegalAccessException {
MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class));
MethodType bigType = cat.type().insertParameterTypes(0, String.class, String.class, int.class);
return new Object[][] {
{cat, -1, bigType.parameterList(), 0},
{cat, 0, bigType.parameterList(), -1},
{cat, 3, bigType.parameterList(), 0},
{cat, 0, bigType.parameterList(), 6},
{cat, 0, bigType.parameterList(), 2}
};
}
示例3: changeArgTypes
import java.lang.invoke.MethodType; //导入方法依赖的package包/类
static MethodHandle changeArgTypes(MethodHandle target,
int beg, int end, Class<?> argType) {
MethodType targetType = target.type();
end = Math.min(end, targetType.parameterCount());
ArrayList<Class<?>> argTypes = new ArrayList<>(targetType.parameterList());
Collections.fill(argTypes.subList(beg, end), argType);
MethodType ttype2 = MethodType.methodType(targetType.returnType(), argTypes);
return target.asType(ttype2);
}
示例4: adapt
import java.lang.invoke.MethodType; //导入方法依赖的package包/类
private TupleHandle adapt(MethodType type, Form form) {
if (this.type.equals(type)) {
return this;
}
int objects = 0;
int prims = 0;
List<Class<?>> parameters = type.parameterList();
int length = parameters.size();
int[] reorder = new int[form.objects + form.prims];
MethodHandle[] cs = new MethodHandle[length];
for(int i = 0; i < length; i++) {
Class<?> parameter = parameters.get(i);
int index = parameter.isPrimitive()? form.objects + prims++: objects++;
MethodHandle c = components[index];
cs[i] = narrow(c, parameter);
reorder[index] = i;
}
// need to fill the holes (objects & prims) for the constructor
int hole = length;
for(int i = objects; i < form.objects; i++) {
reorder[i] = hole++;
}
for(int i = form.objects + prims; i < form.objects + form.prims; i++) {
reorder[i] = hole++;
}
MethodType consType = type.changeReturnType(Object.class);
MethodHandle cons = constructor;
MethodType permutedType = erase(consType);
if (objects < form.objects) {
permutedType = permutedType.appendParameterTypes(classes(Object.class, form.objects - objects));
}
if (prims < form.prims) {
permutedType = permutedType.appendParameterTypes(classes(long.class, form.prims - prims));
}
cons = permuteArguments(cons, permutedType, reorder);
if (objects < form.objects) {
cons = MethodHandles.insertArguments(cons, length, values(null, form.objects - objects));
}
if (prims < form.prims) {
cons = MethodHandles.insertArguments(cons, length, values(0L, form.prims - prims));
}
cons = widen(cons, consType);
return new TupleHandle(type, cons, cs);
}