Cannot deserialize proxy classes
--------------------------------

                 Key: PAXWICKET-25
                 URL: http://issues.ops4j.org/jira/browse/PAXWICKET-25
             Project: Pax Wicket
          Issue Type: Bug
            Reporter: David Leangen
            Assignee: Niclas Hedhman


Proxy classes are not being serialized, which means that they cannot be 
deserialized.

Upon deserialization by Wicket, an exception is thrown.

Currently, this problem can be worked around by doing this:

public class SomeClass
    implements Serialziation
{
    private static final long serialVersionUID = 1L;

    private transient Object someProxy;
    private final InvocationHandler handler;
    private final Class<?>[] proxyInterfaces; 

    public SomeClass( Object someProxyInstance )
    {
        someProxy = someProxyInstance;
        final Class<?> someProxyClass = someProxy.getClass();
        if( Proxy.isProxyClass( someProxyClass ) )
        {
            handler = Proxy.getInvocationHandler( someProxy );
            proxyInterfaces = someProxyClass.getInterfaces();
        }
        else
        {
            handler = null;
            proxyInterfaces = null;
        }
    }

    private void writeObject( ObjectOutputStream out )
        throws IOException
    {
        out.defaultWriteObject();
    }

    private void readObject( ObjectInputStream in )
        throws IOException, ClassNotFoundException
    {
        in.defaultReadObject();

        if( null != m_handler && null != proxyInterfaces )
        {
            someProxy = 
                (Object)Proxy.newProxyInstance( 
                        getClass().getClassLoader(), 
                        proxyInterfaces, 
                        handler );
        }
    }
}

However, this is a really bad solution. The only real solution is to allow 
proxied classes to be properly serialized/deserialized like any other class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.ops4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to