ClassReader exception due to bad bytecode

Buu Vinh <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
After using ASM 3.2 for the bytecode instrumentation, I tried to verify the result by feeding the transformed bytecode to ClassReader and invoking ASMifierClassVisitor:
.........
cr = new ClassReader(originalBytes);
cw = new ClassWriter(cr,ClassWriter.COMPUTE_MAXS);
BciClassAdapter bca = new BciClassAdapter(cw, iClass);
cr.accept(bca, 0);
byte[] newBytes = cw.toByteArray();

ClassReader cr = new ClassReader(newBytes);  
File tmpFile = new File(fileName);
File tmpDir = tmpFile.getParentFile();
tmpDir.mkdirs();
ClassVisitor cv = new ASMifierClassVisitor(new PrintWriter(tmpFile));
cr.accept(cv, 0);
........

I got ClassReader Exception when processing "newBytes":

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 51966   
 at com.bv.asm.ClassReader.readUTF8(ClassReader.java:1946)                 
 at com.bv.asm.ClassReader.readClass(ClassReader.java:2015)                
 at com.bv.asm.ClassReader.getClassName(ClassReader.java:229)              
 at com.bv.bci.instrument.InstrumentClass.verify(InstrumentClass.java:287) 

Apparently ClassReader was not able to parse "newBytes", I assumed that "newBytes" was ill-formated due to some kind of problem in my bytecode instrumenation, but I could not locate the error. I used ClassWriter.COMPUTE_MAXS, but it did not help. Please advice. Thanks
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.