diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2010-07-09 10:20:46 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2010-07-09 10:20:46 +0000 |
commit | 712eedc7e9c102feef07e2bc9082211b770968f8 (patch) | |
tree | b83bb8304a302710a2eb8a277b6b6bd6939cc766 /src/main/javassist/bytecode | |
parent | 0dfd78b0e5a50a9f3531d75a8543d8bdf54df24a (diff) | |
download | javassist-712eedc7e9c102feef07e2bc9082211b770968f8.tar.gz javassist-712eedc7e9c102feef07e2bc9082211b770968f8.zip |
fixed JASSIST-124
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@554 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode')
-rw-r--r-- | src/main/javassist/bytecode/CodeIterator.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/main/javassist/bytecode/CodeIterator.java b/src/main/javassist/bytecode/CodeIterator.java index bb10232c..7781b702 100644 --- a/src/main/javassist/bytecode/CodeIterator.java +++ b/src/main/javassist/bytecode/CodeIterator.java @@ -978,10 +978,10 @@ public class CodeIterator implements Opcode { offset += gapLength; } else if (i == where) { - if (target < where && exclusive) + // This code is different from the code in Branch#shiftOffset(). + // see JASSIST-124. + if (target < where) offset -= gapLength; - else if (where < target && !exclusive) - offset += gapLength; } else if (target < where || (!exclusive && where == target)) @@ -1272,6 +1272,28 @@ public class CodeIterator implements Opcode { pos += gapLength; } + static int shiftOffset(int i, int offset, int where, + int gapLength, boolean exclusive) { + int target = i + offset; + if (i < where) { + if (where < target || (exclusive && where == target)) + offset += gapLength; + } + else if (i == where) { + // This code is different from the code in CodeIterator#newOffset(). + // see JASSIST-124. + if (target < where && exclusive) + offset -= gapLength; + else if (where < target && !exclusive) + offset += gapLength; + } + else + if (target < where || (!exclusive && where == target)) + offset -= gapLength; + + return offset; + } + boolean expanded() { return false; } int gapChanged() { return 0; } int deltaSize() { return 0; } // newSize - oldSize @@ -1323,7 +1345,7 @@ public class CodeIterator implements Opcode { } void shift(int where, int gapLength, boolean exclusive) { - offset = newOffset(pos, offset, where, gapLength, exclusive); + offset = shiftOffset(pos, offset, where, gapLength, exclusive); super.shift(where, gapLength, exclusive); if (state == BIT16) if (offset < Short.MIN_VALUE || Short.MAX_VALUE < offset) @@ -1411,7 +1433,7 @@ public class CodeIterator implements Opcode { } void shift(int where, int gapLength, boolean exclusive) { - offset = newOffset(pos, offset, where, gapLength, exclusive); + offset = shiftOffset(pos, offset, where, gapLength, exclusive); super.shift(where, gapLength, exclusive); } @@ -1435,10 +1457,10 @@ public class CodeIterator implements Opcode { void shift(int where, int gapLength, boolean exclusive) { int p = pos; - defaultByte = newOffset(p, defaultByte, where, gapLength, exclusive); + defaultByte = shiftOffset(p, defaultByte, where, gapLength, exclusive); int num = offsets.length; for (int i = 0; i < num; i++) - offsets[i] = newOffset(p, offsets[i], where, gapLength, exclusive); + offsets[i] = shiftOffset(p, offsets[i], where, gapLength, exclusive); super.shift(where, gapLength, exclusive); } |