@RuntimeType public Object intercept(@AllArguments Object[] args, @Origin Method method, @This Object proxy) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { HK2TestContext testContext = context.getTestContext().get(); SystemInjecteeImpl injectee = context.getInjectee(); Object instance; ServiceLocatorImpl locator = testContext.getLocator(); ActiveDescriptor<?> descriptor = locator.getInjecteeDescriptor(injectee); // if we don't find a descriptor it could be that the injectee is an // assisted injection and can be resolved using it's injection resolver. if (descriptor == null) { instance = LOCATOR_UTIL.getInjectionResolver(locator, injectee).resolve(injectee, null); } else { instance = locator.getService(descriptor, null, injectee); } // if any instance argument is a proxied service then unpack it by // getting the the acutal service and set it as the argument. for (int i = 0; i < args.length; i++) { Object arg = args[i]; if (arg instanceof ProxyService) { args[i] = ((ProxyService) arg)._getService(); } } return method.invoke(instance, args); }