Commit 837657f5 authored by ekuleshov's avatar ekuleshov
Browse files

fix for issue when variable slot is reused for different variable type:

  public int aa(int v1) {
    if(v1>1) {
      long vl11 = 11L;
      return (int) vl11;
    }
    int vi11 = 11;
    return vi11;
  }
parent 07d1b647
...@@ -101,7 +101,8 @@ public class LocalVariablesSorter extends MethodAdapter { ...@@ -101,7 +101,8 @@ public class LocalVariablesSorter extends MethodAdapter {
final Label end, final Label end,
final int index) final int index)
{ {
mv.visitLocalVariable(name, desc, signature, start, end, remap(index)); int size = "J".equals(desc) || "D".equals(desc) ? 2 : 1;
mv.visitLocalVariable(name, desc, signature, start, end, remap(index, size));
} }
// ------------- // -------------
...@@ -131,19 +132,5 @@ public class LocalVariablesSorter extends MethodAdapter { ...@@ -131,19 +132,5 @@ public class LocalVariablesSorter extends MethodAdapter {
} }
return value - 1; return value - 1;
} }
private int remap(final int var) {
if (var < firstLocal) {
return var;
}
int key = 2 * var;
int value = key < mapping.length ? mapping[key] : 0;
if (value == 0) {
value = key + 1 < mapping.length ? mapping[key + 1] : 0;
}
if (value == 0) {
throw new IllegalStateException("Unknown local variable " + var);
}
return value - 1;
}
} }
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