@@ -0,0 +1,2215 @@
+package net.fushizen.invokedynamic.proxy;%0A%0Aimport org.junit.Test;%0A%0Aimport java.lang.invoke.ConstantCallSite;%0Aimport java.lang.invoke.MethodHandle;%0Aimport java.lang.invoke.MethodType;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Apublic class StatefulProxyTest %7B%0A    public abstract static class StateSuperclass %7B%0A        private int counter;%0A%0A        protected void invokeIncrement() %7B%0A            counter++;%0A        %7D%0A%0A        protected int invokeGet() %7B%0A            return counter;%0A        %7D%0A    %7D%0A%0A    public interface Counter %7B%0A        public void increment();%0A        public int get();%0A    %7D%0A%0A    @Test%0A    public void testStatefulProxy() throws Exception %7B%0A        DynamicInvocationHandler handler = (lookup, name, type, superMethod) -%3E %7B%0A            Class%3C?%3E proxyType = type.parameterArray()%5B0%5D;%0A            MethodHandle mh;%0A%0A            if (superMethod != null) %7B%0A                mh = superMethod.asType(type);%0A            %7D else if (name.equals(%22increment%22)) %7B%0A                mh = lookup.findSpecial(%0A                        StateSuperclass.class,%0A                        %22invokeIncrement%22,%0A                        MethodType.methodType(Void.TYPE),%0A                        proxyType%0A                ).asType(type); // downcast the 'this' parameter%0A            %7D else if (name.equals(%22get%22)) %7B%0A                mh = lookup.findSpecial(%0A                        StateSuperclass.class,%0A                        %22invokeGet%22,%0A                        MethodType.methodType(Integer.TYPE),%0A                        proxyType%0A                ).asType(type); // downcast the 'this' parameter%0A            %7D else %7B%0A                throw new UnsupportedOperationException();%0A            %7D%0A%0A            return new ConstantCallSite(mh);%0A        %7D;%0A%0A        DynamicProxy proxy = DynamicProxy.builder()%0A                .withSuperclass(StateSuperclass.class)%0A                .withInterfaces(Counter.class)%0A                .withInvocationHandler(handler)%0A                .build();%0A%0A        Counter counter1 = (Counter)proxy.supplier().get();%0A        Counter counter2 = (Counter)proxy.supplier().get();%0A%0A        counter1.increment();%0A%0A        assertEquals(1, counter1.get());%0A        assertEquals(0, counter2.get());%0A    %7D%0A%0A%0A%7D%0A

Add a test demonstrating a stateful proxy