diff options
author | chibash <chiba@javassist.org> | 2015-01-25 18:16:48 +0900 |
---|---|---|
committer | chibash <chiba@javassist.org> | 2015-01-25 18:16:48 +0900 |
commit | e59339343a538699b632bd9fa0cf4f251ab6f3ee (patch) | |
tree | 3a0f9f1c3d8d9058a787057b519377f43d3e1775 /src/main/javassist/CtBehavior.java | |
parent | e8c023af06f04877ccc83911c6f6900574486a6c (diff) | |
download | javassist-e59339343a538699b632bd9fa0cf4f251ab6f3ee.tar.gz javassist-e59339343a538699b632bd9fa0cf4f251ab6f3ee.zip |
fixed JIRA JASSIST-241
Diffstat (limited to 'src/main/javassist/CtBehavior.java')
-rw-r--r-- | src/main/javassist/CtBehavior.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java index 92513159..ede73422 100644 --- a/src/main/javassist/CtBehavior.java +++ b/src/main/javassist/CtBehavior.java @@ -917,7 +917,9 @@ public abstract class CtBehavior extends CtMember { // the gap length might be a multiple of 4. iterator.writeByte(Opcode.NOP, pos); boolean wide = subr + 2 - pos > Short.MAX_VALUE; - pos = iterator.insertGapAt(pos, wide ? 4 : 2, false).position; + int len = wide ? 4 : 2; + CodeIterator.Gap gap = iterator.insertGapAt(pos, len, false); + pos = gap.position + gap.length - len; int offset = iterator.getMark() - pos; if (wide) { iterator.writeByte(Opcode.GOTO_W, pos); @@ -928,7 +930,11 @@ public abstract class CtBehavior extends CtMember { iterator.write16bit(offset, pos + 1); } else { - pos = iterator.insertGapAt(pos, 2, false).position; + if (gap.length < 4) { + CodeIterator.Gap gap2 = iterator.insertGapAt(gap.position, 2, false); + pos = gap2.position + gap2.length + gap.length - 4; + } + iterator.writeByte(Opcode.GOTO_W, pos); iterator.write32bit(iterator.getMark() - pos, pos + 1); } |