I find out what was not allowing insertGap to work well.
I am instrumenting a method using CodeIterator. With the same iterator that I use to insert gaps into the method I also use writeByte to modify bytes. When I do this the gaps are inserted at the end.
I used two separate iterators to solve the problem. The first run inserts gaps and the second run modifies the bytecode. It would be better if I could insert gaps and modify the bytecode with the same iterator.
Well, if your post is really true, that behavior is a bug.
Can you show me a test case (simple one is fine)?