/** * Resolve the serialized proxy to a real instance. * * @return the resolved instance * @throws ObjectStreamException if an error occurs */ protected Object readResolve() throws ObjectStreamException { try { Class<?> proxyClass = getProxyClass(); Object instance = proxyClass.newInstance(); ProxyFactory.setInvocationHandlerStatic(instance, handler); return instance; } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }