Stefano Bagnara wrote:

On 9/23/05, Stefano Bagnara <[EMAIL PROTECTED]> wrote:
Are you sure?
IIRC "new Class[] { conn.getClass()}" as the second
parameter will fail.
You are probably using the Proxy from net.sf.cglib.proxy
and not the
one from java.lang.reflect.
Please go read the javadocs for java.lang.reflect.Proxy!

I've done it and also tested it and the 2 documented methods are:

"getProxyClass(ClassLoader loader, Class[] INTERFACES)"
"newProxyInstance(ClassLoader loader, Class[] INTERFACES, InvocationHandler
h) "
And the javadocs say:
"All of the Class objects in the interfaces array must represent interfaces,
not classes or primitive types."

So, if I understand correctly (and I've tested it right), your proxy can
only implement interfaces and will not be castable to concrete classes (like
MimeMessage).
Yep . that's the way it is - make sure you also pick up the interfaces of any base class and a cast to the implementation class fails miserably (I'm just back from adding dynamic proxies and interceptors to my pet application)

I've also created proxies for concrete Classes but I used the cglib Proxy
instead of the java.lang.reflect.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to