Java Code Examples for jdk.internal.dynalink.CallSiteDescriptor#changeMethodType()

The following examples show how to use jdk.internal.dynalink.CallSiteDescriptor#changeMethodType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private GuardedInvocation createVarArgApplyOrCallCall(final boolean isApply, final CallSiteDescriptor desc,
        final LinkRequest request, final Object[] args) {
    final MethodType descType = desc.getMethodType();
    final int paramCount = descType.parameterCount();
    final Object[] varArgs = (Object[]) args[paramCount - 1];
    // -1 'cause we're not passing the vararg array itself
    final int copiedArgCount = args.length - 1;
    final int varArgCount = varArgs.length;

    // Spread arguments for the delegate createApplyOrCallCall invocation.
    final Object[] spreadArgs = new Object[copiedArgCount + varArgCount];
    System.arraycopy(args, 0, spreadArgs, 0, copiedArgCount);
    System.arraycopy(varArgs, 0, spreadArgs, copiedArgCount, varArgCount);

    // Spread call site descriptor for the delegate createApplyOrCallCall invocation. We drop vararg array and
    // replace it with a list of Object.class.
    final MethodType spreadType = descType.dropParameterTypes(paramCount - 1, paramCount).appendParameterTypes(
            Collections.<Class<?>>nCopies(varArgCount, Object.class));
    final CallSiteDescriptor spreadDesc = desc.changeMethodType(spreadType);

    // Delegate back to createApplyOrCallCall with the spread (that is, reverted to non-vararg) request/
    final LinkRequest spreadRequest = request.replaceArguments(spreadDesc, spreadArgs);
    final GuardedInvocation spreadInvocation = createApplyOrCallCall(isApply, spreadDesc, spreadRequest, spreadArgs);

    // Add spreader combinators to returned invocation and guard.
    return spreadInvocation.replaceMethods(
            // Use standard ScriptObject.pairArguments on the invocation
            pairArguments(spreadInvocation.getInvocation(), descType),
            // Use our specialized spreadGuardArguments on the guard (see below).
            spreadGuardArguments(spreadInvocation.getGuard(), descType));
}
 
Example 2
private GuardedInvocation createVarArgApplyOrCallCall(final boolean isApply, final CallSiteDescriptor desc,
        final LinkRequest request, final Object[] args) {
    final MethodType descType = desc.getMethodType();
    final int paramCount = descType.parameterCount();
    final Object[] varArgs = (Object[])args[paramCount - 1];
    // -1 'cause we're not passing the vararg array itself
    final int copiedArgCount = args.length - 1;
    final int varArgCount = varArgs.length;

    // Spread arguments for the delegate createApplyOrCallCall invocation.
    final Object[] spreadArgs = new Object[copiedArgCount + varArgCount];
    System.arraycopy(args, 0, spreadArgs, 0, copiedArgCount);
    System.arraycopy(varArgs, 0, spreadArgs, copiedArgCount, varArgCount);

    // Spread call site descriptor for the delegate createApplyOrCallCall invocation. We drop vararg array and
    // replace it with a list of Object.class.
    final MethodType spreadType = descType.dropParameterTypes(paramCount - 1, paramCount).appendParameterTypes(
            Collections.<Class<?>>nCopies(varArgCount, Object.class));
    final CallSiteDescriptor spreadDesc = desc.changeMethodType(spreadType);

    // Delegate back to createApplyOrCallCall with the spread (that is, reverted to non-vararg) request/
    final LinkRequest spreadRequest = request.replaceArguments(spreadDesc, spreadArgs);
    final GuardedInvocation spreadInvocation = createApplyOrCallCall(isApply, spreadDesc, spreadRequest, spreadArgs);

    // Add spreader combinators to returned invocation and guard.
    return spreadInvocation.replaceMethods(
            // Use standard ScriptObject.pairArguments on the invocation
            pairArguments(spreadInvocation.getInvocation(), descType),
            // Use our specialized spreadGuardArguments on the guard (see below).
            spreadGuardArguments(spreadInvocation.getGuard(), descType));
}
 
Example 3
private GuardedInvocation createVarArgApplyOrCallCall(final boolean isApply, final CallSiteDescriptor desc,
        final LinkRequest request, final Object[] args) {
    final MethodType descType = desc.getMethodType();
    final int paramCount = descType.parameterCount();
    final Object[] varArgs = (Object[]) args[paramCount - 1];
    // -1 'cause we're not passing the vararg array itself
    final int copiedArgCount = args.length - 1;
    final int varArgCount = varArgs.length;

    // Spread arguments for the delegate createApplyOrCallCall invocation.
    final Object[] spreadArgs = new Object[copiedArgCount + varArgCount];
    System.arraycopy(args, 0, spreadArgs, 0, copiedArgCount);
    System.arraycopy(varArgs, 0, spreadArgs, copiedArgCount, varArgCount);

    // Spread call site descriptor for the delegate createApplyOrCallCall invocation. We drop vararg array and
    // replace it with a list of Object.class.
    final MethodType spreadType = descType.dropParameterTypes(paramCount - 1, paramCount).appendParameterTypes(
            Collections.<Class<?>>nCopies(varArgCount, Object.class));
    final CallSiteDescriptor spreadDesc = desc.changeMethodType(spreadType);

    // Delegate back to createApplyOrCallCall with the spread (that is, reverted to non-vararg) request/
    final LinkRequest spreadRequest = request.replaceArguments(spreadDesc, spreadArgs);
    final GuardedInvocation spreadInvocation = createApplyOrCallCall(isApply, spreadDesc, spreadRequest, spreadArgs);

    // Add spreader combinators to returned invocation and guard.
    return spreadInvocation.replaceMethods(
            // Use standard ScriptObject.pairArguments on the invocation
            pairArguments(spreadInvocation.getInvocation(), descType),
            // Use our specialized spreadGuardArguments on the guard (see below).
            spreadGuardArguments(spreadInvocation.getGuard(), descType));
}
 
Example 4
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception {
    final Object objBoundCallable = linkRequest.getReceiver();
    if(!(objBoundCallable instanceof BoundCallable)) {
        return null;
    }

    final CallSiteDescriptor descriptor = linkRequest.getCallSiteDescriptor();
    if (descriptor.getNameTokenCount() < 2 || !"dyn".equals(descriptor.getNameToken(CallSiteDescriptor.SCHEME))) {
        return null;
    }
    final String operation = descriptor.getNameToken(CallSiteDescriptor.OPERATOR);
    // We need to distinguish "dyn:new" from "dyn:call" because "dyn:call" sites have parameter list of the form
    // "callee, this, args", while "dyn:call" sites have "callee, args" -- they lack the "this" parameter.
    final boolean isCall;
    if ("new".equals(operation)) {
        isCall = false;
    } else if ("call".equals(operation)) {
        isCall = true;
    } else {
        // Only dyn:call and dyn:new are supported.
        return null;
    }
    final BoundCallable boundCallable = (BoundCallable)objBoundCallable;
    final Object callable = boundCallable.getCallable();
    final Object boundThis = boundCallable.getBoundThis();

    // We need to ask the linker services for a delegate invocation on the target callable.

    // Replace arguments (boundCallable[, this], args) => (callable[, boundThis], boundArgs, args) when delegating
    final Object[] args = linkRequest.getArguments();
    final Object[] boundArgs = boundCallable.getBoundArgs();
    final int argsLen = args.length;
    final int boundArgsLen = boundArgs.length;
    final Object[] newArgs = new Object[argsLen + boundArgsLen];
    newArgs[0] = callable;
    final int firstArgIndex;
    if (isCall) {
        newArgs[1] = boundThis;
        firstArgIndex = 2;
    } else {
        firstArgIndex = 1;
    }
    System.arraycopy(boundArgs, 0, newArgs, firstArgIndex, boundArgsLen);
    System.arraycopy(args, firstArgIndex, newArgs, firstArgIndex + boundArgsLen, argsLen - firstArgIndex);

    // Use R(T0, T1, T2, ...) => R(callable.class, boundThis.class, boundArg0.class, ..., boundArgn.class, T2, ...)
    // call site type when delegating to underlying linker (for dyn:new, there's no this).
    final MethodType type = descriptor.getMethodType();
    // Use R(T0, ...) => R(callable.class, ...)
    MethodType newMethodType = descriptor.getMethodType().changeParameterType(0, callable.getClass());
    if (isCall) {
        // R(callable.class, T1, ...) => R(callable.class, boundThis.class, ...)
        newMethodType = newMethodType.changeParameterType(1, boundThis == null? Object.class : boundThis.getClass());
    }
    // R(callable.class[, boundThis.class], T2, ...) => R(callable.class[, boundThis.class], boundArg0.class, ..., boundArgn.class, T2, ...)
    for(int i = boundArgs.length; i-- > 0;) {
        newMethodType = newMethodType.insertParameterTypes(firstArgIndex, boundArgs[i] == null ? Object.class : boundArgs[i].getClass());
    }
    final CallSiteDescriptor newDescriptor = descriptor.changeMethodType(newMethodType);

    // Delegate to target's linker
    final GuardedInvocation inv = linkerServices.getGuardedInvocation(linkRequest.replaceArguments(newDescriptor, newArgs));
    if(inv == null) {
        return null;
    }

    // Bind (callable[, boundThis], boundArgs) to the delegate handle
    final MethodHandle boundHandle = MethodHandles.insertArguments(inv.getInvocation(), 0,
            Arrays.copyOf(newArgs, firstArgIndex + boundArgs.length));
    final Class<?> p0Type = type.parameterType(0);
    final MethodHandle droppingHandle;
    if (isCall) {
        // Ignore incoming boundCallable and this
        droppingHandle = MethodHandles.dropArguments(boundHandle, 0, p0Type, type.parameterType(1));
    } else {
        // Ignore incoming boundCallable
        droppingHandle = MethodHandles.dropArguments(boundHandle, 0, p0Type);
    }
    // Identity guard on boundCallable object
    final MethodHandle newGuard = Guards.getIdentityGuard(boundCallable);
    return inv.replaceMethods(droppingHandle, newGuard.asType(newGuard.type().changeParameterType(0, p0Type)));
}
 
Example 5
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, LinkerServices linkerServices) throws Exception {
    final Object objBoundDynamicMethod = linkRequest.getReceiver();
    if(!(objBoundDynamicMethod instanceof BoundDynamicMethod)) {
        return null;
    }

    final BoundDynamicMethod boundDynamicMethod = (BoundDynamicMethod)objBoundDynamicMethod;
    final Object dynamicMethod = boundDynamicMethod.getDynamicMethod();
    final Object boundThis = boundDynamicMethod.getBoundThis();

    // Replace arguments (boundDynamicMethod, this, ...) => (dynamicMethod, boundThis, ...) when delegating to
    // BeansLinker
    final Object[] args = linkRequest.getArguments();
    args[0] = dynamicMethod;
    args[1] = boundThis;

    // Use R(T0, T1, ...) => R(dynamicMethod.class, boundThis.class, ...) call site type when delegating to
    // BeansLinker.
    final CallSiteDescriptor descriptor = linkRequest.getCallSiteDescriptor();
    final MethodType type = descriptor.getMethodType();
    final Class<?> dynamicMethodClass = dynamicMethod.getClass();
    final CallSiteDescriptor newDescriptor = descriptor.changeMethodType(
            type.changeParameterType(0, dynamicMethodClass).changeParameterType(1, boundThis.getClass()));

    // Delegate to BeansLinker
    final GuardedInvocation inv = NashornBeansLinker.getGuardedInvocation(BeansLinker.getLinkerForClass(dynamicMethodClass),
            linkRequest.replaceArguments(newDescriptor, args), linkerServices);
    if(inv == null) {
        return null;
    }

    // Bind (dynamicMethod, boundThis) to the handle
    final MethodHandle boundHandle = MethodHandles.insertArguments(inv.getInvocation(), 0, dynamicMethod, boundThis);
    final Class<?> p0Type = type.parameterType(0);
    // Ignore incoming (boundDynamicMethod, this)
    final MethodHandle droppingHandle = MethodHandles.dropArguments(boundHandle, 0, p0Type, type.parameterType(1));
    // Identity guard on boundDynamicMethod object
    final MethodHandle newGuard = Guards.getIdentityGuard(boundDynamicMethod);

    return inv.replaceMethods(droppingHandle, newGuard.asType(newGuard.type().changeParameterType(0, p0Type)));
}
 
Example 6
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, LinkerServices linkerServices) throws Exception {
    final Object objBoundDynamicMethod = linkRequest.getReceiver();
    if(!(objBoundDynamicMethod instanceof BoundDynamicMethod)) {
        return null;
    }

    final BoundDynamicMethod boundDynamicMethod = (BoundDynamicMethod)objBoundDynamicMethod;
    final Object dynamicMethod = boundDynamicMethod.getDynamicMethod();
    final Object boundThis = boundDynamicMethod.getBoundThis();

    // Replace arguments (boundDynamicMethod, this, ...) => (dynamicMethod, boundThis, ...) when delegating to
    // BeansLinker
    final Object[] args = linkRequest.getArguments();
    args[0] = dynamicMethod;
    args[1] = boundThis;

    // Use R(T0, T1, ...) => R(dynamicMethod.class, boundThis.class, ...) call site type when delegating to
    // BeansLinker.
    final CallSiteDescriptor descriptor = linkRequest.getCallSiteDescriptor();
    final MethodType type = descriptor.getMethodType();
    final Class<?> dynamicMethodClass = dynamicMethod.getClass();
    final CallSiteDescriptor newDescriptor = descriptor.changeMethodType(
            type.changeParameterType(0, dynamicMethodClass).changeParameterType(1, boundThis.getClass()));

    // Delegate to BeansLinker
    final GuardedInvocation inv = NashornBeansLinker.getGuardedInvocation(BeansLinker.getLinkerForClass(dynamicMethodClass),
            linkRequest.replaceArguments(newDescriptor, args), linkerServices);
    if(inv == null) {
        return null;
    }

    // Bind (dynamicMethod, boundThis) to the handle
    final MethodHandle boundHandle = MethodHandles.insertArguments(inv.getInvocation(), 0, dynamicMethod, boundThis);
    final Class<?> p0Type = type.parameterType(0);
    // Ignore incoming (boundDynamicMethod, this)
    final MethodHandle droppingHandle = MethodHandles.dropArguments(boundHandle, 0, p0Type, type.parameterType(1));
    // Identity guard on boundDynamicMethod object
    final MethodHandle newGuard = Guards.getIdentityGuard(boundDynamicMethod);

    return inv.replaceMethods(droppingHandle, newGuard.asType(newGuard.type().changeParameterType(0, p0Type)));
}
 
Example 7
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception {
    final Object objBoundCallable = linkRequest.getReceiver();
    if(!(objBoundCallable instanceof BoundCallable)) {
        return null;
    }

    final CallSiteDescriptor descriptor = linkRequest.getCallSiteDescriptor();
    if (descriptor.getNameTokenCount() < 2 || !"dyn".equals(descriptor.getNameToken(CallSiteDescriptor.SCHEME))) {
        return null;
    }
    final String operation = descriptor.getNameToken(CallSiteDescriptor.OPERATOR);
    // We need to distinguish "dyn:new" from "dyn:call" because "dyn:call" sites have parameter list of the form
    // "callee, this, args", while "dyn:call" sites have "callee, args" -- they lack the "this" parameter.
    final boolean isCall;
    if ("new".equals(operation)) {
        isCall = false;
    } else if ("call".equals(operation)) {
        isCall = true;
    } else {
        // Only dyn:call and dyn:new are supported.
        return null;
    }
    final BoundCallable boundCallable = (BoundCallable)objBoundCallable;
    final Object callable = boundCallable.getCallable();
    final Object boundThis = boundCallable.getBoundThis();

    // We need to ask the linker services for a delegate invocation on the target callable.

    // Replace arguments (boundCallable[, this], args) => (callable[, boundThis], boundArgs, args) when delegating
    final Object[] args = linkRequest.getArguments();
    final Object[] boundArgs = boundCallable.getBoundArgs();
    final int argsLen = args.length;
    final int boundArgsLen = boundArgs.length;
    final Object[] newArgs = new Object[argsLen + boundArgsLen];
    newArgs[0] = callable;
    final int firstArgIndex;
    if (isCall) {
        newArgs[1] = boundThis;
        firstArgIndex = 2;
    } else {
        firstArgIndex = 1;
    }
    System.arraycopy(boundArgs, 0, newArgs, firstArgIndex, boundArgsLen);
    System.arraycopy(args, firstArgIndex, newArgs, firstArgIndex + boundArgsLen, argsLen - firstArgIndex);

    // Use R(T0, T1, T2, ...) => R(callable.class, boundThis.class, boundArg0.class, ..., boundArgn.class, T2, ...)
    // call site type when delegating to underlying linker (for dyn:new, there's no this).
    final MethodType type = descriptor.getMethodType();
    // Use R(T0, ...) => R(callable.class, ...)
    MethodType newMethodType = descriptor.getMethodType().changeParameterType(0, callable.getClass());
    if (isCall) {
        // R(callable.class, T1, ...) => R(callable.class, boundThis.class, ...)
        newMethodType = newMethodType.changeParameterType(1, boundThis == null? Object.class : boundThis.getClass());
    }
    // R(callable.class[, boundThis.class], T2, ...) => R(callable.class[, boundThis.class], boundArg0.class, ..., boundArgn.class, T2, ...)
    for(int i = boundArgs.length; i-- > 0;) {
        newMethodType = newMethodType.insertParameterTypes(firstArgIndex, boundArgs[i] == null ? Object.class : boundArgs[i].getClass());
    }
    final CallSiteDescriptor newDescriptor = descriptor.changeMethodType(newMethodType);

    // Delegate to target's linker
    final GuardedInvocation inv = linkerServices.getGuardedInvocation(linkRequest.replaceArguments(newDescriptor, newArgs));
    if(inv == null) {
        return null;
    }

    // Bind (callable[, boundThis], boundArgs) to the delegate handle
    final MethodHandle boundHandle = MethodHandles.insertArguments(inv.getInvocation(), 0,
            Arrays.copyOf(newArgs, firstArgIndex + boundArgs.length));
    final Class<?> p0Type = type.parameterType(0);
    final MethodHandle droppingHandle;
    if (isCall) {
        // Ignore incoming boundCallable and this
        droppingHandle = MethodHandles.dropArguments(boundHandle, 0, p0Type, type.parameterType(1));
    } else {
        // Ignore incoming boundCallable
        droppingHandle = MethodHandles.dropArguments(boundHandle, 0, p0Type);
    }
    // Identity guard on boundCallable object
    final MethodHandle newGuard = Guards.getIdentityGuard(boundCallable);
    return inv.replaceMethods(droppingHandle, newGuard.asType(newGuard.type().changeParameterType(0, p0Type)));
}
 
Example 8
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has a single parameter
 * type changed in its method type.
 * @param desc the original call site descriptor
 * @param num index of the parameter to change
 * @param nptype the new parameter type
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor changeParameterType(CallSiteDescriptor desc, int num, Class<?> nptype) {
    return desc.changeMethodType(desc.getMethodType().changeParameterType(num, nptype));
}
 
Example 9
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(CallSiteDescriptor desc, int num, Class<?>... ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
 
Example 10
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final Class<?>... ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
 
Example 11
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final Class<?>... ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
 
Example 12
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final List<Class<?>> ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
 
Example 13
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has some parameter types
 * removed from its method type.
 * @param desc the original call site descriptor
 * @param start index of the first parameter to remove
 * @param end index of the first parameter to not remove
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor dropParameterTypes(CallSiteDescriptor desc, int start, int end) {
    return desc.changeMethodType(desc.getMethodType().dropParameterTypes(start, end));
}
 
Example 14
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has the return type
 * changed in its method type.
 * @param desc the original call site descriptor
 * @param nrtype the new return type
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor changeReturnType(final CallSiteDescriptor desc, final Class<?> nrtype) {
    return desc.changeMethodType(desc.getMethodType().changeReturnType(nrtype));
}
 
Example 15
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has some parameter types
 * removed from its method type.
 * @param desc the original call site descriptor
 * @param start index of the first parameter to remove
 * @param end index of the first parameter to not remove
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor dropParameterTypes(final CallSiteDescriptor desc, final int start, final int end) {
    return desc.changeMethodType(desc.getMethodType().dropParameterTypes(start, end));
}
 
Example 16
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has some parameter types
 * removed from its method type.
 * @param desc the original call site descriptor
 * @param start index of the first parameter to remove
 * @param end index of the first parameter to not remove
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor dropParameterTypes(final CallSiteDescriptor desc, final int start, final int end) {
    return desc.changeMethodType(desc.getMethodType().dropParameterTypes(start, end));
}
 
Example 17
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(CallSiteDescriptor desc, int num, Class<?>... ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
 
Example 18
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final List<Class<?>> ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
 
Example 19
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has a single parameter
 * type changed in its method type.
 * @param desc the original call site descriptor
 * @param num index of the parameter to change
 * @param nptype the new parameter type
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor changeParameterType(CallSiteDescriptor desc, int num, Class<?> nptype) {
    return desc.changeMethodType(desc.getMethodType().changeParameterType(num, nptype));
}
 
Example 20
/**
 * Returns a new call site descriptor that is identical to the passed one, except that it has additional parameter
 * types inserted into its method type.
 * @param desc the original call site descriptor
 * @param num index at which the new parameters are inserted
 * @param ptypesToInsert the new types to insert
 * @return a new call site descriptor with modified method type
 */
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final Class<?>... ptypesToInsert) {
    return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}