public final class LocalVariableTag extends Tag {
private final UnresolvedType type;
private final String name;
- private final int slot;
+ private int slot;
private final int startPos;
+ boolean remapped = false;
// AMC - pr101047, two local vars with the same name can share the same slot, but must in that case
// have different start positions.
return type;
}
+ public void updateSlot(int newSlot) {
+ this.slot = newSlot;
+ this.remapped = true;
+ }
+
+ public boolean isRemapped() { return this.remapped; }
+
// ---- from Object
public String toString() {
// System.err.println("JUST COPIED: " + oldIh.getInstruction().toString(freshMethod.getEnclosingClass().getConstantPoolGen().getConstantPool())
// + " INTO " + freshIh.getInstruction().toString(freshMethod.getEnclosingClass().getConstantPoolGen().getConstantPool()));
}
+
+ // now go through again and update variable slots that have been altered as a result
+ // of remapping...
+ for (InstructionHandle newIh = freshBody.getStart(); newIh != freshBody.getEnd(); newIh = newIh.getNext()) {
+ InstructionTargeter[] sources = newIh.getTargeters();
+ if (sources != null) {
+ for (int i = sources.length - 1; i >= 0; i--) {
+ if (sources[i] instanceof LocalVariableTag) {
+ LocalVariableTag lvt = (LocalVariableTag) sources[i];
+ if (!lvt.isRemapped() && remap.hasKey(lvt.getSlot())) {
+ lvt.updateSlot(remap.get(lvt.getSlot()));
+ }
+ }
+ }
+ }
+ }
+
+
+
// we've now copied out all the instructions.
// now delete the instructions... we've already taken care of the damn
ASTORE_3 (line 9)
finally -> E1
| catch java.lang.Exception -> E0
- | | ALOAD_3 (line 11)
+ | | ALOAD_3 // java.io.PrintStream out (line 11)
| | LDC "bye"
| | ASTORE 5
| | ASTORE 7
| | GOTO L0
| catch java.lang.Exception -> E0
| E0: ASTORE 11 (line 12)
- | ALOAD_3 (line 13)
- | ALOAD 11
+ | ALOAD_3 // java.io.PrintStream out (line 13)
+ | ALOAD 11 // java.lang.Exception e
| ASTORE 13
| ASTORE 15
| method-call(void java.io.PrintStream.println(java.lang.Object))
L0: JSR L1
GOTO L2
L1: ASTORE 21
- ALOAD_3 (line 15)
+ ALOAD_3 // java.io.PrintStream out (line 15)
LDC "finally"
ASTORE 23
ASTORE 25
ASTORE_3 (line 9)
finally -> E1
| catch java.lang.Exception -> E0
- | | ALOAD_3 (line 11)
+ | | ALOAD_3 // java.io.PrintStream out (line 11)
| | LDC "bye"
| | ASTORE 5
| | ASTORE 7
| | GOTO L0
| catch java.lang.Exception -> E0
| E0: ASTORE 11 (line 12)
- | ALOAD_3 (line 13)
- | ALOAD 11
+ | ALOAD_3 // java.io.PrintStream out (line 13)
+ | ALOAD 11 // java.lang.Exception e
| ASTORE 13
| ASTORE 15
| method-call(void java.io.PrintStream.println(java.lang.Object))
L0: JSR L1
GOTO L2
L1: ASTORE 21
- ALOAD_3 (line 15)
+ ALOAD_3 // java.io.PrintStream out (line 15)
LDC "finally"
ASTORE 23
ASTORE 25