Re: ClassReader exception due to bad bytecode

Buu Vinh <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Thanks for the suggestion. The result of javap - v -p as following:

Exception in thread "main" java.lang.NullPointerException
        at sun.tools.javap.JavapPrinter.javaclassname(JavapPrinter.java:856)
        at sun.tools.javap.JavapPrinter.printclassHeader(JavapPrinter.java:62)
        at sun.tools.javap.JavapPrinter.print(JavapPrinter.java:38)
        at sun.tools.javap.Main.displayResults(Main.java:202)
        at sun.tools.javap.Main.perform(Main.java:61)
        at sun.tools.javap.Main.entry(Main.java:49)
        at sun.tools.javap.Main.main(Main.java:34)

I can't tell what is wrong with my bytecode based on the above messages. I would guess the problem is in the header, is it a wild guess? Are there tools that help to identify problems in the bytecode? Please advice.

--- On Tue, 1/25/11, Dave Brosius <[email protected]> wrote:

From: Dave Brosius <[email protected]>
Subject: Re: [asm] ClassReader exception due to bad bytecode
To: [email protected], [email protected]
Date: Tuesday, January 25, 2011, 7:20 PM



  

    
    
  Does javap -v -private YourClass

    

    produce anything different?

    

    On 01/25/2011 04:54 PM, 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
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.