Java Code Examples for jdk.internal.dynalink.CallSiteDescriptor#getNameToken()
The following examples show how to use
jdk.internal.dynalink.CallSiteDescriptor#getNameToken() .
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
Source File: BeansLinker.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception { final CallSiteDescriptor callSiteDescriptor = request.getCallSiteDescriptor(); final int l = callSiteDescriptor.getNameTokenCount(); // All names conforming to the dynalang MOP should have at least two tokens, the first one being "dyn" if(l < 2 || "dyn" != callSiteDescriptor.getNameToken(CallSiteDescriptor.SCHEME)) { return null; } final Object receiver = request.getReceiver(); if(receiver == null) { // Can't operate on null return null; } return getLinkerForClass(receiver.getClass()).getGuardedInvocation(request, linkerServices); }
Example 2
Source File: Global.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); final boolean isScope = NashornCallSiteDescriptor.isScope(desc); if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) { if (lexicalScope.hasOwnProperty(name)) { return lexicalScope.findGetMethod(desc, request, operator); } } final GuardedInvocation invocation = super.findGetMethod(desc, request, operator); // We want to avoid adding our generic lexical scope switchpoint to global constant invocations, // because those are invalidated per-key in the addBoundProperties method above. // We therefore check if the invocation does already have a switchpoint and the property is non-inherited, // assuming this only applies to global constants. If other non-inherited properties will // start using switchpoints some time in the future we'll have to revisit this. if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) { return invocation.addSwitchPoint(getLexicalScopeSwitchPoint()); } return invocation; }
Example 3
Source File: AbstractJavaLinker.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception { final LinkRequest ncrequest = request.withoutRuntimeContext(); // BeansLinker already checked that the name is at least 2 elements long and the first element is "dyn". final CallSiteDescriptor callSiteDescriptor = ncrequest.getCallSiteDescriptor(); final String op = callSiteDescriptor.getNameToken(CallSiteDescriptor.OPERATOR); // Either dyn:callMethod:name(this[,args]) or dyn:callMethod(this,name[,args]). if("callMethod" == op) { return getCallPropWithThis(callSiteDescriptor, linkerServices); } List<String> operations = CallSiteDescriptorFactory.tokenizeOperators(callSiteDescriptor); while(!operations.isEmpty()) { final GuardedInvocationComponent gic = getGuardedInvocationComponent(callSiteDescriptor, linkerServices, operations); if(gic != null) { return gic.getGuardedInvocation(); } operations = pop(operations); } return null; }
Example 4
Source File: Global.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final boolean isScope = NashornCallSiteDescriptor.isScope(desc); if (lexicalScope != null && isScope) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (lexicalScope.hasOwnProperty(name)) { return lexicalScope.findSetMethod(desc, request); } } final GuardedInvocation invocation = super.findSetMethod(desc, request); if (isScope && context.getEnv()._es6) { return invocation.addSwitchPoint(getLexicalScopeSwitchPoint()); } return invocation; }
Example 5
Source File: Global.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@Override public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final boolean isScope = NashornCallSiteDescriptor.isScope(desc); if (lexicalScope != null && isScope) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (lexicalScope.hasOwnProperty(name)) { return lexicalScope.findSetMethod(desc, request); } } final GuardedInvocation invocation = super.findSetMethod(desc, request); if (isScope && context.getEnv()._es6) { return invocation.addSwitchPoint(getLexicalScopeSwitchPoint()); } return invocation; }
Example 6
Source File: NativeJavaPackage.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Handle creation of new attribute. * @param desc the call site descriptor * @param request the link request * @return Link to be invoked at call site. */ @Override public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) { final String propertyName = desc.getNameToken(2); final String fullName = name.isEmpty() ? propertyName : name + "." + propertyName; final Context context = Context.getContextTrusted(); Class<?> javaClass = null; try { javaClass = context.findClass(fullName); } catch (final NoClassDefFoundError | ClassNotFoundException e) { //ignored } if (javaClass == null) { set(propertyName, new NativeJavaPackage(fullName, getProto()), false); } else { set(propertyName, StaticClass.forClass(javaClass), false); } return super.lookup(desc, request); }
Example 7
Source File: NativeJSAdapter.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) { if (overrides && super.hasOwnProperty(desc.getNameToken(2))) { try { final GuardedInvocation inv = super.findCallMethodMethod(desc, request); if (inv != null) { return inv; } } catch (final Exception e) { //ignored } } return findHook(desc, __call__); }
Example 8
Source File: NativeString.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) { final String name = desc.getNameToken(2); // if str.length(), then let the bean linker handle it if ("length".equals(name) && "getMethod".equals(operator)) { return null; } return super.findGetMethod(desc, request, operator); }
Example 9
Source File: NativeJSAdapter.java From nashorn with GNU General Public License v2.0 | 5 votes |
@Override protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) { if (overrides && super.hasOwnProperty(desc.getNameToken(2))) { try { final GuardedInvocation inv = super.findCallMethodMethod(desc, request); if (inv != null) { return inv; } } catch (final Exception e) { //ignored } } return findHook(desc, __call__); }
Example 10
Source File: NativeJavaImporter.java From nashorn with GNU General Public License v2.0 | 5 votes |
private boolean createAndSetProperty(final CallSiteDescriptor desc) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); final Object value = createProperty(name); if(value != null) { set(name, value, false); return true; } return false; }
Example 11
Source File: NativeJSAdapter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { if (overrides && super.hasOwnProperty(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND))) { try { final GuardedInvocation inv = super.findSetMethod(desc, request); if (inv != null) { return inv; } } catch (final Exception e) { //ignored } } return findHook(desc, __put__); }
Example 12
Source File: NativeJavaPackage.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Handle creation of new attribute. * @param desc the call site descriptor * @param request the link request * @return Link to be invoked at call site. */ @Override public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) { final String propertyName = desc.getNameToken(2); createProperty(propertyName); return super.lookup(desc, request); }
Example 13
Source File: NativeJSAdapter.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operation) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (overrides && super.hasOwnProperty(name)) { try { final GuardedInvocation inv = super.findGetMethod(desc, request, operation); if (inv != null) { return inv; } } catch (final Exception e) { //ignored } } switch(operation) { case "getProp": case "getElem": return findHook(desc, __get__); case "getMethod": final FindProperty find = adaptee.findProperty(__call__, true); if (find != null) { final Object value = find.getObjectValue(); if (value instanceof ScriptFunction) { final ScriptFunction func = (ScriptFunction)value; // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice. return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class, func.createBound(this, new Object[] { name })), 0, Object.class), testJSAdaptor(adaptee, null, null, null), adaptee.getProtoSwitchPoints(__call__, find.getOwner()), null); } } throw typeError("no.such.function", desc.getNameToken(2), ScriptRuntime.safeToString(this)); default: break; } throw new AssertionError("should not reach here"); }
Example 14
Source File: ScriptObject.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 15
Source File: WithObject.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 16
Source File: ScriptObject.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 17
Source File: BoundCallableLinker.java From hottub with GNU General Public License v2.0 | 4 votes |
@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 18
Source File: JSObjectLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name); return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); }
Example 19
Source File: JSObjectLinker.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name); return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); }
Example 20
Source File: BoundCallableLinker.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@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))); }