修复创建RestServlet时方法内含try/catch导致获取方法参数名错位的BUG

This commit is contained in:
Redkale
2017-09-01 10:51:41 +08:00
parent 222dc0edce
commit 182a75cfad
2 changed files with 20 additions and 2 deletions

View File

@@ -92,7 +92,16 @@ public final class Rest {
return new MethodVisitor(Opcodes.ASM5) {
@Override
public void visitLocalVariable(String name, String description, String signature, Label start, Label end, int index) {
if (index > 0) fieldnames.add(name);
if (index < 1) return;
int size = fieldnames.size();
//index并不会按顺序执行的
if (index > size) {
for (int i = size; i < index; i++) {
fieldnames.add(" ");
}
fieldnames.set(index - 1, name);
}
fieldnames.set(index - 1, name);
}
};
}

View File

@@ -109,7 +109,16 @@ public interface Creator<T> {
return new MethodVisitor(Opcodes.ASM5) {
@Override
public void visitLocalVariable(String name, String description, String signature, Label start, Label end, int index) {
if (index > 0) fieldnames.add(name);
if (index < 1) return;
int size = fieldnames.size();
//index不会按顺序执行的
if (index > size) {
for (int i = size; i < index; i++) {
fieldnames.add(" ");
}
fieldnames.set(index - 1, name);
}
fieldnames.set(index - 1, name);
}
};
}