Commit 7aad9cd9 authored by ekuleshov's avatar ekuleshov
Browse files

fixed issue with incorrect recalculation of max locals when source method has...

fixed issue with incorrect recalculation of max locals when source method has unused vars in the debug info
parent a3bbcbae
......@@ -35,6 +35,7 @@ package org.objectweb.asm;
* instruction to a byte vector, in the order these methods are called.
*
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
class MethodWriter implements MethodVisitor {
......@@ -1055,6 +1056,15 @@ class MethodWriter implements MethodVisitor {
.putShort(cw.newUTF8(name))
.putShort(cw.newUTF8(desc))
.putShort(index);
if(computeMaxs) {
// updates max locals
char c = desc.charAt(0);
int n = index + ( c=='L' || c=='D' ? 2 : 1);
if (n > maxLocals) {
maxLocals = n;
}
}
}
public void visitLineNumber(final int line, final Label start) {
......
......@@ -50,7 +50,7 @@ public class LocalVariablesSorterTest extends AbstractTest {
public void test() throws Exception {
ClassReader cr = new ClassReader(is);
ClassWriter cw = new ClassWriter(false, true);
ClassWriter cw = new ClassWriter(true, true);
cr.accept(new ClassAdapter(cw) {
public MethodVisitor visitMethod(
int access,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment