Bug: CheckMethodAdapter.visitMaxs() doesn't take ClassWriter.COMPUTE_FRAMES into account

Prashant Deva <[email protected]> Wed, 30 Apr 2014 13:29:43 -0700
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CAEg0NFb+j_h9P2riYazpwKs==J=3ju8yKownDdcRVfgxEhrC6g@mail.gmail.com>
Since apparently on the bug tracker it says login is not available, i am
posting this here:


If you use a ClassWriter with ClassWriter.COMPUTE_FRAMES to auto calculate
the max stack size, and you have code like this:


                ClassWriter classWriter = new ClassWriter(classReader,
ClassWriter.COMPUTE_FRAMES);
                classReader.accept(new MyClassInstrumentor(new
CheckClassAdapter(classWriter)), ClassReader.EXPAND_FRAMES);

                return classWriter.toByteArray();

in your custom method instrumentor when you do this:

@Override
    public void visitMaxs(int maxStack, int maxLocals)
    {

       //perfectly valid, since due to expand_frames i can pass in anything
here
        super.visitMaxs(0, 0);
    }

the CheckMethodAdapater will throw an exception, because it does expect the
exact stack size.

com.chronon.apm.libs.org.objectweb.asm.tree.analysis.AnalyzerException:
Error at instruction 0: Insufficient maximum stack size.
at
com.chronon.apm.libs.org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown
Source)
 at
com.chronon.apm.libs.org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown
Source)
at com.chronon.apm.libs.org.objectweb.asm.MethodVisitor.visitEnd(Unknown
Source)
 at
com.chronon.apm.libs.org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown
Source)
at com.chronon.apm.libs.org.objectweb.asm.MethodVisitor.visitEnd(Unknown
Source)
 at com.chronon.apm.libs.org.objectweb.asm.ClassReader.b(Unknown Source)

Prashant
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