@Test public void testExceptions() { final ThreadLocalInvoker<X> tli = new ThreadLocalInvoker<>(); final X x = (X) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{X.class}, tli); tli.set(new X() { public String checked() throws CheckedException { throw new CheckedException(); } public String runtime() { throw new RuntimeException(); } }); boolean caught = false; try { x.checked(); } catch (final Exception ex) { caught = true; assertEquals(CheckedException.class, ex.getClass()); } assertTrue(caught); caught = false; try { x.runtime(); } catch (final Exception ex) { caught = true; assertEquals(RuntimeException.class, ex.getClass()); } assertTrue(caught); }
public void set(final T threadLocalInstance) { this.threadLocalInstance.set(threadLocalInstance); }
ThreadLocalInvoker implements InvocationHandler { public void set(final T threadLocalInstance) { this.threadLocalInstance.set(threadLocalInstance); } }
ThreadLocalInvoker implements InvocationHandler { public void set(final T threadLocalInstance) { this.threadLocalInstance.set(threadLocalInstance); }  }
ThreadLocalInvoker implements InvocationHandler { public void set(final T threadLocalInstance) { this.threadLocalInstance.set(threadLocalInstance); }  void set(final T threadLocalInstance); T get(); @Override Object invoke(final Object proxy, final Method method, final Object[] args); }
ThreadLocalInvoker implements InvocationHandler { public void set(final T threadLocalInstance) { this.threadLocalInstance.set(threadLocalInstance); }  void set(final T threadLocalInstance); T get(); @Override Object invoke(final Object proxy, final Method method, final Object[] args);  }