@Override public Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { UsesAdsUtilities utilityAnnotation = method.getAnnotation(UsesAdsUtilities.class); if (utilityAnnotation != null && utilityAnnotation.value() != null) { for (AdsUtility utility : utilityAnnotation.value()) { this.adsUtilityRegistry.addUtility(utility); } } try { return method.invoke(objectToProxy, args); } catch (InvocationTargetException e) { if (e.getCause() != null) { throw e.getCause(); } // An InvocationTargetException shouldn't have a null cause, but it's technically // possible since its constructors don't explicitly disallow null. In the unlikely // event that this happens, wrap the InvocationTargetException and throw it. throw new RuntimeException("Method invocation failed", e); } } }
@Override public Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { UsesAdsUtilities utilityAnnotation = method.getAnnotation(UsesAdsUtilities.class); if (utilityAnnotation != null && utilityAnnotation.value() != null) { for (AdsUtility utility : utilityAnnotation.value()) { this.adsUtilityRegistry.addUtility(utility); } } try { return method.invoke(objectToProxy, args); } catch (InvocationTargetException e) { if (e.getCause() != null) { throw e.getCause(); } // An InvocationTargetException shouldn't have a null cause, but it's technically // possible since its constructors don't explicitly disallow null. In the unlikely // event that this happens, wrap the InvocationTargetException and throw it. throw new RuntimeException("Method invocation failed", e); } } }