private static MethodHandle bindWithFallback( MethodHandle mh, RoboCallSite site, MethodHandle fallback) { SwitchPoint switchPoint = getInvalidator(site.getCaller()); MethodType type = site.type(); MethodHandle boundFallback = foldArguments(exactInvoker(type), fallback.bindTo(site)); mh = switchPoint.guardWithTest(mh.asType(type), boundFallback); site.setTarget(mh); return mh; }
private static MethodHandle bindInitCallSite(RoboCallSite site) { MethodHandle mh = RobolectricInternals.getShadowCreator(site.getCaller()); return bindWithFallback(mh, site, BIND_INIT_CALL_SITE); }