Re: ClassReader exception due to bad bytecode
Tronje Krop <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Organization | Darmstadt University of Technology |
| Message-ID | <[email protected]> |
Hi Buu,
org.objectweb.asm.util.CheckClassAdapter is your friend. It has a more
verbose output of failure reasons in your instrumented code.
Best regards
Tronje
Buu Vinh wrote:
> 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
>
>
>
--
Tronje Krop <[email protected]>
Encrypted eMail welcome! GPG/PGP-Key: 0x9AD43A05
68E5 A3D3 75A0 B096 AC75 62D5 8EEE 3D18 9AD4 3A05
No responsibility is taken for the correctness of the
previous information. Please delete if you receive this
mail unintentional.
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