@Test public void testHandleUnexpectedMethod() { DeepThoughtSync sync = SyncClientAdapterHandler.newHandler(DeepThoughtSync.class, Object.class, new Object()); try { sync.answerQuestionOfLifeUniverseAndEverything(); fail("No exception thrown."); } catch (UndeclaredThrowableException e) { assertThat(e.getCause()).isInstanceOf(NoSuchMethodException.class); } }
public static <S, A> S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass, A delegateAdapter) { SyncClientAdapterHandler handler = new SyncClientAdapterHandler(asyncIfcClass, delegateAdapter); Class<?>[] ifcClasses = new Class<?>[]{syncIfcClass}; return syncIfcClass.cast(Proxy.newProxyInstance(syncIfcClass.getClassLoader(), ifcClasses, handler)); }
SyncClientAdapterHandler implements InvocationHandler { public static <S, A> S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass, A delegateAdapter) { SyncClientAdapterHandler handler = new SyncClientAdapterHandler(asyncIfcClass, delegateAdapter); Class<?>[] ifcClasses = new Class<?>[]{syncIfcClass}; return syncIfcClass.cast(Proxy.newProxyInstance(syncIfcClass.getClassLoader(), ifcClasses, handler)); } }
SyncClientAdapterHandler implements InvocationHandler { public static <S, A> S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass, A delegateAdapter) { SyncClientAdapterHandler handler = new SyncClientAdapterHandler(asyncIfcClass, delegateAdapter); Class<?>[] ifcClasses = new Class<?>[]{syncIfcClass}; return syncIfcClass.cast(Proxy.newProxyInstance(syncIfcClass.getClassLoader(), ifcClasses, handler)); } private  SyncClientAdapterHandler(Class<?> asyncIfcClass, Object delegate); }
SyncClientAdapterHandler implements InvocationHandler { public static <S, A> S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass, A delegateAdapter) { SyncClientAdapterHandler handler = new SyncClientAdapterHandler(asyncIfcClass, delegateAdapter); Class<?>[] ifcClasses = new Class<?>[]{syncIfcClass}; return syncIfcClass.cast(Proxy.newProxyInstance(syncIfcClass.getClassLoader(), ifcClasses, handler)); } private  SyncClientAdapterHandler(Class<?> asyncIfcClass, Object delegate); static S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass,
                                      A delegateAdapter); @Override Object invoke(Object proxy, Method method, Object[] args); }
SyncClientAdapterHandler implements InvocationHandler { public static <S, A> S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass, A delegateAdapter) { SyncClientAdapterHandler handler = new SyncClientAdapterHandler(asyncIfcClass, delegateAdapter); Class<?>[] ifcClasses = new Class<?>[]{syncIfcClass}; return syncIfcClass.cast(Proxy.newProxyInstance(syncIfcClass.getClassLoader(), ifcClasses, handler)); } private  SyncClientAdapterHandler(Class<?> asyncIfcClass, Object delegate); static S newHandler(Class<? extends S> syncIfcClass, Class<? super A> asyncIfcClass,
                                      A delegateAdapter); @Override Object invoke(Object proxy, Method method, Object[] args);  }