302 argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
303 break;
304 default:
305 final int NON_SPREAD_ARG_COUNT = 3; // (caller, name, type)
306 if (NON_SPREAD_ARG_COUNT + argv.length > MethodType.MAX_MH_ARITY)
307 throw new BootstrapMethodError("too many bootstrap method arguments");
308 MethodType bsmType = bootstrapMethod.type();
309 MethodType invocationType = MethodType.genericMethodType(NON_SPREAD_ARG_COUNT + argv.length);
310 MethodHandle typedBSM = bootstrapMethod.asType(invocationType);
311 MethodHandle spreader = invocationType.invokers().spreadInvoker(NON_SPREAD_ARG_COUNT);
312 binding = spreader.invokeExact(typedBSM, (Object)caller, (Object)name, (Object)type, argv);
313 }
314 }
315 //System.out.println("BSM for "+name+type+" => "+binding);
316 if (binding instanceof CallSite) {
317 site = (CallSite) binding;
318 } else {
319 throw new ClassCastException("bootstrap method failed to produce a CallSite");
320 }
321 if (!site.getTarget().type().equals(type))
322 throw new WrongMethodTypeException("wrong type: "+site.getTarget());
323 } catch (Throwable ex) {
324 BootstrapMethodError bex;
325 if (ex instanceof BootstrapMethodError)
326 bex = (BootstrapMethodError) ex;
327 else
328 bex = new BootstrapMethodError("call site initialization exception", ex);
329 throw bex;
330 }
331 return site;
332 }
333
334 private static Object maybeReBox(Object x) {
335 if (x instanceof Integer) {
336 int xi = (int) x;
337 if (xi == (byte) xi)
338 x = xi; // must rebox; see JLS 5.1.7
339 }
340 return x;
341 }
342 private static void maybeReBoxElements(Object[] xa) {
|
302 argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
303 break;
304 default:
305 final int NON_SPREAD_ARG_COUNT = 3; // (caller, name, type)
306 if (NON_SPREAD_ARG_COUNT + argv.length > MethodType.MAX_MH_ARITY)
307 throw new BootstrapMethodError("too many bootstrap method arguments");
308 MethodType bsmType = bootstrapMethod.type();
309 MethodType invocationType = MethodType.genericMethodType(NON_SPREAD_ARG_COUNT + argv.length);
310 MethodHandle typedBSM = bootstrapMethod.asType(invocationType);
311 MethodHandle spreader = invocationType.invokers().spreadInvoker(NON_SPREAD_ARG_COUNT);
312 binding = spreader.invokeExact(typedBSM, (Object)caller, (Object)name, (Object)type, argv);
313 }
314 }
315 //System.out.println("BSM for "+name+type+" => "+binding);
316 if (binding instanceof CallSite) {
317 site = (CallSite) binding;
318 } else {
319 throw new ClassCastException("bootstrap method failed to produce a CallSite");
320 }
321 if (!site.getTarget().type().equals(type))
322 throw wrongTargetType(site.getTarget(), type);
323 } catch (Throwable ex) {
324 BootstrapMethodError bex;
325 if (ex instanceof BootstrapMethodError)
326 bex = (BootstrapMethodError) ex;
327 else
328 bex = new BootstrapMethodError("call site initialization exception", ex);
329 throw bex;
330 }
331 return site;
332 }
333
334 private static Object maybeReBox(Object x) {
335 if (x instanceof Integer) {
336 int xi = (int) x;
337 if (xi == (byte) xi)
338 x = xi; // must rebox; see JLS 5.1.7
339 }
340 return x;
341 }
342 private static void maybeReBoxElements(Object[] xa) {
|