src/jdk/internal/dynalink/beans/SingleDynamicMethod.java

changeset 1239
e1146c9cc758
parent 963
e2497b11a021
child 1490
d85f981c8cf8
child 1530
fd307cc5f58c
equal deleted inserted replaced
1238:4dee46412516 1239:e1146c9cc758
163 * @param callSiteType the type of the call site 163 * @param callSiteType the type of the call site
164 * @param linkerServices the linker services used for type conversions 164 * @param linkerServices the linker services used for type conversions
165 * @return the adapted method handle. 165 * @return the adapted method handle.
166 */ 166 */
167 static MethodHandle getInvocation(final MethodHandle target, final MethodType callSiteType, final LinkerServices linkerServices) { 167 static MethodHandle getInvocation(final MethodHandle target, final MethodType callSiteType, final LinkerServices linkerServices) {
168 final MethodType methodType = target.type(); 168 final MethodHandle filteredTarget = linkerServices.filterInternalObjects(target);
169 final MethodType methodType = filteredTarget.type();
169 final int paramsLen = methodType.parameterCount(); 170 final int paramsLen = methodType.parameterCount();
170 final boolean varArgs = target.isVarargsCollector(); 171 final boolean varArgs = target.isVarargsCollector();
171 final MethodHandle fixTarget = varArgs ? target.asFixedArity() : target; 172 final MethodHandle fixTarget = varArgs ? filteredTarget.asFixedArity() : filteredTarget;
172 final int fixParamsLen = varArgs ? paramsLen - 1 : paramsLen; 173 final int fixParamsLen = varArgs ? paramsLen - 1 : paramsLen;
173 final int argsLen = callSiteType.parameterCount(); 174 final int argsLen = callSiteType.parameterCount();
174 if(argsLen < fixParamsLen) { 175 if(argsLen < fixParamsLen) {
175 // Less actual arguments than number of fixed declared arguments; can't invoke. 176 // Less actual arguments than number of fixed declared arguments; can't invoke.
176 return null; 177 return null;
202 if(argsLen == paramsLen) { 203 if(argsLen == paramsLen) {
203 final Class<?> callSiteLastArgType = callSiteType.parameterType(fixParamsLen); 204 final Class<?> callSiteLastArgType = callSiteType.parameterType(fixParamsLen);
204 if(varArgType.isAssignableFrom(callSiteLastArgType)) { 205 if(varArgType.isAssignableFrom(callSiteLastArgType)) {
205 // Call site signature guarantees we'll always be passed a single compatible array; just link directly 206 // Call site signature guarantees we'll always be passed a single compatible array; just link directly
206 // to the method, introducing necessary conversions. Also, preserve it being a variable arity method. 207 // to the method, introducing necessary conversions. Also, preserve it being a variable arity method.
207 return createConvertingInvocation(target, linkerServices, callSiteType).asVarargsCollector( 208 return createConvertingInvocation(filteredTarget, linkerServices, callSiteType).asVarargsCollector(
208 callSiteLastArgType); 209 callSiteLastArgType);
209 } 210 }
210 211
211 // This method handle takes the single argument and packs it into a newly allocated single-element array. It 212 // This method handle takes the single argument and packs it into a newly allocated single-element array. It
212 // will be used when the incoming argument can't be converted to the vararg array type (the "vararg packer" 213 // will be used when the incoming argument can't be converted to the vararg array type (the "vararg packer"

mercurial