本文整理匯總了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);
}