Hi,
I've got a class that implements and interface, let's say:

public class MyClass implements MyInterface{}

I use javassist to add the method from another class, and to obtain a new 
object of kind MyClass with the added method. It works, and in fact if I 
perform introspection, I can find the added method and I can see that 
getClass().getName() gives me MyClass. However, if I try to cast the class from 
MyInterface (that works) to MyClass it does not work, and an exception is 
thrown:

MyClass myclazz = new MyClass();
MyInterface object = .....// manipulation of myclazz
myclazz = (MyClass) object; // ClassCastException here!

Now, I use the interface in all the manipulation process, but I don't think it 
can be the problem. In fact, as I told you, if I print the class information, I 
can see that the manipulated class is of the MyClass class, and implements the 
MyInterface. Any idea? I'm using javassist 3.

Thanks,
Luca

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884406#3884406

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884406


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to