[jboss-user] [Javassist] New message: "Re: Remove an interface from a Class"

Arvind K do-not-reply at jboss.com
Thu Feb 25 06:35:29 EST 2010


User development,

A new message was posted in the thread "Remove an interface from a Class":

http://community.jboss.org/message/528432#528432

Author  : Arvind K
Profile : http://community.jboss.org/people/megalodon

Message:
--------------------------------------------------------------
Hello,
 
I do not think there should be anything wrong with the interface-removing part. You can verify this by printing the interface class names before and after you change them, if you need. I can think of 2 possibilities for the exception:
 
I would put my money on this one:
1. You are trying to modify a class that has already been loaded. This is not allowed by the JVM. You might have seen this thread in a forum that posts your same error: http://lists.jboss.org/pipermail/jboss-user/2009-March/152559.html. You might want to modify your class during load time in this case using a javaagent and classfiletransformer (or some other approach).
 
2. You might need a different context class loader to load the ContextBarItem class. The default CtClass.toClass() uses the context class loader of the current thread. You could use an overloaded Class:
public java.lang.Class *toClass*(java.lang.ClassLoader loader,
                               java.security.ProtectionDomain domain)

                        throws 
 
suppose the object of ContextBarItem class is myCBI,
Class newClass = cc.toClass(myCBI.getClass().getClassloader(), myCBI.getClass().getProtectionDomain());
 
Check out http://www.csg.is.titech.ac.jp/~chiba/javassist/tutorial/tutorial.html#toclass and Javassist API for more details. I'm not too clear on these concepts either.
 
-Arvind

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/528432#528432




More information about the jboss-user mailing list