类java.lang.invoke.LambdaForm.BasicType源码实例Demo

下面列出了怎么用java.lang.invoke.LambdaForm.BasicType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk1.8-source-analysis   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码2 项目: dragonwell8_jdk   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码3 项目: TencentKona-8   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码4 项目: jdk8u60   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码5 项目: JDKSourceCode1.8   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码6 项目: openjdk-jdk8u   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码8 项目: jdk8u-jdk   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码9 项目: Java8CN   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码10 项目: hottub   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码11 项目: jdk8u_jdk   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码12 项目: jdk8u-jdk   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码13 项目: jdk8u-dev-jdk   文件: MethodHandles.java
static
MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
    filterArgumentChecks(target, pos, filter);
    MethodType targetType = target.type();
    MethodType filterType = filter.type();
    BoundMethodHandle result = target.rebind();
    Class<?> newParamType = filterType.parameterType(0);
    LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
    MethodType newType = targetType.changeParameterType(pos, newParamType);
    result = result.copyWithExtendL(newType, lform, filter);
    return result;
}
 
源代码14 项目: jdk1.8-source-analysis   文件: MethodHandles.java
private static MethodHandle makeIdentity(Class<?> ptype) {
    MethodType mtype = MethodType.methodType(ptype, ptype);
    LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
 
源代码15 项目: jdk1.8-source-analysis   文件: MethodHandles.java
private static MethodHandle makeZero(Class<?> rtype) {
    MethodType mtype = MethodType.methodType(rtype);
    LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
 
源代码16 项目: jdk1.8-source-analysis   文件: MethodHandles.java
/**
     * Produces a method handle which will discard some dummy arguments
     * before calling some other specified <i>target</i> method handle.
     * The type of the new method handle will be the same as the target's type,
     * except it will also include the dummy argument types,
     * at some given position.
     * <p>
     * The {@code pos} argument may range between zero and <i>N</i>,
     * where <i>N</i> is the arity of the target.
     * If {@code pos} is zero, the dummy arguments will precede
     * the target's real arguments; if {@code pos} is <i>N</i>
     * they will come after.
     * <p>
     * <b>Example:</b>
     * <blockquote><pre>{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
...
MethodHandle cat = lookup().findVirtual(String.class,
  "concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
assertEquals(bigType, d0.type());
assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
     * }</pre></blockquote>
     * <p>
     * This method is also equivalent to the following code:
     * <blockquote><pre>
     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
     * </pre></blockquote>
     * @param target the method handle to invoke after the arguments are dropped
     * @param valueTypes the type(s) of the argument(s) to drop
     * @param pos position of first argument to drop (zero for the leftmost)
     * @return a method handle which drops arguments of the given types,
     *         before calling the original method handle
     * @throws NullPointerException if the target is null,
     *                              or if the {@code valueTypes} list or any of its elements is null
     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
     *                  or if {@code pos} is negative or greater than the arity of the target,
     *                  or if the new method handle's type would have too many parameters
     */
    public static
    MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
        valueTypes = copyTypes(valueTypes);
        MethodType oldType = target.type();  // get NPE
        int dropped = dropArgumentChecks(oldType, pos, valueTypes);
        MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
        if (dropped == 0)  return target;
        BoundMethodHandle result = target.rebind();
        LambdaForm lform = result.form;
        int insertFormArg = 1 + pos;
        for (Class<?> ptype : valueTypes) {
            lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype));
        }
        result = result.copyWith(newType, lform);
        return result;
    }
 
源代码17 项目: dragonwell8_jdk   文件: MethodHandles.java
private static MethodHandle makeIdentity(Class<?> ptype) {
    MethodType mtype = MethodType.methodType(ptype, ptype);
    LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
 
源代码18 项目: dragonwell8_jdk   文件: MethodHandles.java
private static MethodHandle makeZero(Class<?> rtype) {
    MethodType mtype = MethodType.methodType(rtype);
    LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
 
源代码19 项目: dragonwell8_jdk   文件: MethodHandles.java
/**
     * Produces a method handle which will discard some dummy arguments
     * before calling some other specified <i>target</i> method handle.
     * The type of the new method handle will be the same as the target's type,
     * except it will also include the dummy argument types,
     * at some given position.
     * <p>
     * The {@code pos} argument may range between zero and <i>N</i>,
     * where <i>N</i> is the arity of the target.
     * If {@code pos} is zero, the dummy arguments will precede
     * the target's real arguments; if {@code pos} is <i>N</i>
     * they will come after.
     * <p>
     * <b>Example:</b>
     * <blockquote><pre>{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
...
MethodHandle cat = lookup().findVirtual(String.class,
  "concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
assertEquals(bigType, d0.type());
assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
     * }</pre></blockquote>
     * <p>
     * This method is also equivalent to the following code:
     * <blockquote><pre>
     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
     * </pre></blockquote>
     * @param target the method handle to invoke after the arguments are dropped
     * @param valueTypes the type(s) of the argument(s) to drop
     * @param pos position of first argument to drop (zero for the leftmost)
     * @return a method handle which drops arguments of the given types,
     *         before calling the original method handle
     * @throws NullPointerException if the target is null,
     *                              or if the {@code valueTypes} list or any of its elements is null
     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
     *                  or if {@code pos} is negative or greater than the arity of the target,
     *                  or if the new method handle's type would have too many parameters
     */
    public static
    MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
        valueTypes = copyTypes(valueTypes);
        MethodType oldType = target.type();  // get NPE
        int dropped = dropArgumentChecks(oldType, pos, valueTypes);
        MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
        if (dropped == 0)  return target;
        BoundMethodHandle result = target.rebind();
        LambdaForm lform = result.form;
        int insertFormArg = 1 + pos;
        for (Class<?> ptype : valueTypes) {
            lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype));
        }
        result = result.copyWith(newType, lform);
        return result;
    }
 
源代码20 项目: TencentKona-8   文件: MethodHandles.java
private static MethodHandle makeIdentity(Class<?> ptype) {
    MethodType mtype = MethodType.methodType(ptype, ptype);
    LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
 
源代码21 项目: TencentKona-8   文件: MethodHandles.java
private static MethodHandle makeZero(Class<?> rtype) {
    MethodType mtype = MethodType.methodType(rtype);
    LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
 
源代码22 项目: TencentKona-8   文件: MethodHandles.java
/**
     * Produces a method handle which will discard some dummy arguments
     * before calling some other specified <i>target</i> method handle.
     * The type of the new method handle will be the same as the target's type,
     * except it will also include the dummy argument types,
     * at some given position.
     * <p>
     * The {@code pos} argument may range between zero and <i>N</i>,
     * where <i>N</i> is the arity of the target.
     * If {@code pos} is zero, the dummy arguments will precede
     * the target's real arguments; if {@code pos} is <i>N</i>
     * they will come after.
     * <p>
     * <b>Example:</b>
     * <blockquote><pre>{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
...
MethodHandle cat = lookup().findVirtual(String.class,
  "concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
assertEquals(bigType, d0.type());
assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
     * }</pre></blockquote>
     * <p>
     * This method is also equivalent to the following code:
     * <blockquote><pre>
     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
     * </pre></blockquote>
     * @param target the method handle to invoke after the arguments are dropped
     * @param valueTypes the type(s) of the argument(s) to drop
     * @param pos position of first argument to drop (zero for the leftmost)
     * @return a method handle which drops arguments of the given types,
     *         before calling the original method handle
     * @throws NullPointerException if the target is null,
     *                              or if the {@code valueTypes} list or any of its elements is null
     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
     *                  or if {@code pos} is negative or greater than the arity of the target,
     *                  or if the new method handle's type would have too many parameters
     */
    public static
    MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
        valueTypes = copyTypes(valueTypes);
        MethodType oldType = target.type();  // get NPE
        int dropped = dropArgumentChecks(oldType, pos, valueTypes);
        MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
        if (dropped == 0)  return target;
        BoundMethodHandle result = target.rebind();
        LambdaForm lform = result.form;
        int insertFormArg = 1 + pos;
        for (Class<?> ptype : valueTypes) {
            lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype));
        }
        result = result.copyWith(newType, lform);
        return result;
    }
 
源代码23 项目: jdk8u60   文件: MethodHandles.java
private static MethodHandle makeIdentity(Class<?> ptype) {
    MethodType mtype = MethodType.methodType(ptype, ptype);
    LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
 
源代码24 项目: jdk8u60   文件: MethodHandles.java
private static MethodHandle makeZero(Class<?> rtype) {
    MethodType mtype = MethodType.methodType(rtype);
    LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
 
源代码25 项目: jdk8u60   文件: MethodHandles.java
/**
     * Produces a method handle which will discard some dummy arguments
     * before calling some other specified <i>target</i> method handle.
     * The type of the new method handle will be the same as the target's type,
     * except it will also include the dummy argument types,
     * at some given position.
     * <p>
     * The {@code pos} argument may range between zero and <i>N</i>,
     * where <i>N</i> is the arity of the target.
     * If {@code pos} is zero, the dummy arguments will precede
     * the target's real arguments; if {@code pos} is <i>N</i>
     * they will come after.
     * <p>
     * <b>Example:</b>
     * <blockquote><pre>{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
...
MethodHandle cat = lookup().findVirtual(String.class,
  "concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
assertEquals(bigType, d0.type());
assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
     * }</pre></blockquote>
     * <p>
     * This method is also equivalent to the following code:
     * <blockquote><pre>
     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
     * </pre></blockquote>
     * @param target the method handle to invoke after the arguments are dropped
     * @param valueTypes the type(s) of the argument(s) to drop
     * @param pos position of first argument to drop (zero for the leftmost)
     * @return a method handle which drops arguments of the given types,
     *         before calling the original method handle
     * @throws NullPointerException if the target is null,
     *                              or if the {@code valueTypes} list or any of its elements is null
     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
     *                  or if {@code pos} is negative or greater than the arity of the target,
     *                  or if the new method handle's type would have too many parameters
     */
    public static
    MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
        MethodType oldType = target.type();  // get NPE
        int dropped = dropArgumentChecks(oldType, pos, valueTypes);
        MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
        if (dropped == 0)  return target;
        BoundMethodHandle result = target.rebind();
        LambdaForm lform = result.form;
        int insertFormArg = 1 + pos;
        for (Class<?> ptype : valueTypes) {
            lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype));
        }
        result = result.copyWith(newType, lform);
        return result;
    }
 
源代码26 项目: JDKSourceCode1.8   文件: MethodHandles.java
private static MethodHandle makeIdentity(Class<?> ptype) {
    MethodType mtype = MethodType.methodType(ptype, ptype);
    LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
 
源代码27 项目: JDKSourceCode1.8   文件: MethodHandles.java
private static MethodHandle makeZero(Class<?> rtype) {
    MethodType mtype = MethodType.methodType(rtype);
    LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
 
源代码28 项目: JDKSourceCode1.8   文件: MethodHandles.java
/**
     * Produces a method handle which will discard some dummy arguments
     * before calling some other specified <i>target</i> method handle.
     * The type of the new method handle will be the same as the target's type,
     * except it will also include the dummy argument types,
     * at some given position.
     * <p>
     * The {@code pos} argument may range between zero and <i>N</i>,
     * where <i>N</i> is the arity of the target.
     * If {@code pos} is zero, the dummy arguments will precede
     * the target's real arguments; if {@code pos} is <i>N</i>
     * they will come after.
     * <p>
     * <b>Example:</b>
     * <blockquote><pre>{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
...
MethodHandle cat = lookup().findVirtual(String.class,
  "concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
assertEquals(bigType, d0.type());
assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
     * }</pre></blockquote>
     * <p>
     * This method is also equivalent to the following code:
     * <blockquote><pre>
     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
     * </pre></blockquote>
     * @param target the method handle to invoke after the arguments are dropped
     * @param valueTypes the type(s) of the argument(s) to drop
     * @param pos position of first argument to drop (zero for the leftmost)
     * @return a method handle which drops arguments of the given types,
     *         before calling the original method handle
     * @throws NullPointerException if the target is null,
     *                              or if the {@code valueTypes} list or any of its elements is null
     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
     *                  or if {@code pos} is negative or greater than the arity of the target,
     *                  or if the new method handle's type would have too many parameters
     */
    public static
    MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
        valueTypes = copyTypes(valueTypes);
        MethodType oldType = target.type();  // get NPE
        int dropped = dropArgumentChecks(oldType, pos, valueTypes);
        MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
        if (dropped == 0)  return target;
        BoundMethodHandle result = target.rebind();
        LambdaForm lform = result.form;
        int insertFormArg = 1 + pos;
        for (Class<?> ptype : valueTypes) {
            lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype));
        }
        result = result.copyWith(newType, lform);
        return result;
    }
 
源代码29 项目: openjdk-jdk8u   文件: MethodHandles.java
private static MethodHandle makeIdentity(Class<?> ptype) {
    MethodType mtype = MethodType.methodType(ptype, ptype);
    LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
 
源代码30 项目: openjdk-jdk8u   文件: MethodHandles.java
private static MethodHandle makeZero(Class<?> rtype) {
    MethodType mtype = MethodType.methodType(rtype);
    LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
    return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
 
 类所在包
 类方法
 同包方法