I've followed this example from notes:

BufferedInputStream fin
    = new BufferedInputStream(new FileInputStream("Point.class"));
ClassFile cf = new ClassFile(new DataInputStream(fin));


And then used the write method to create the new class. However, tad throws an 
exception, so it appears the bytecode is invalid.

Here is my code:

InputStream is = getClass().getResourceAsStream(resourceName);
DataInputStream dis = new DataInputStream(is);
ClassFile cf = new ClassFile(dis);
cf.addInterface(interfaceName);
DataOutputStream dos = new DataOutputStream(new FileOutputStream(
                                        rtDirName + File.separator + "new" + 
".class"));
                        cf.write(dos);
                        dos.flush();
                        dos.close();
                        dis.close();

Any ideas what is wrong? If I use the CtClass regular methods to augment the 
code, it creates valid byte code.


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

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


-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to