I got this to work, just that the classes subclasses now throw 
java.lang.AbstractMethodError exceptions!

// get the class file as a resource
InputStream is = getClass().getResourceAsStream(resourceName);
DataInputStream dis = new DataInputStream(is);
// create a class file object from the class file 
ClassFile cf = new ClassFile(dis);
// modify the class
cf.addInterface(interfaceName);
// create an output stream for the new class
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
// write the new class into a byte array using the data output stream
cf.write(dos);
// close resources
dos.close();
baos.close();
dis.close();
// get the modified class and pass to this classes class loader
is = new ByteArrayInputStream(baos.toByteArray());
// make a class anonymously
CtClass ptc = pool.makeClass(is);
is.close();
// force the class loader to load the modified class
ptc.toClass(getClass().getClassLoader());

At least the class loader gets your new version of the class.



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

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


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to