How did you modify your method with Javassist?
It might be a bug.
Well strangely I didn't actually modify this method, but I have added methods to the class and increased the size of the constant pool enough to make the ldc change to an ldc_w.
Having taken a look at the code and debuged my classes I can see it finding the ldc and creating linked list of the final class LdcEntry. It then iterates through each of these (only two in my case), inserts a gap, and then places the ldc_w opcode plus the 16 bit index. It looks like the insertGap2 method in codeIterator is inserting one NOP opcode but then copying the old ldc opcode into the new code before carrying on with the invokevirtual - if you see what I mean. I don't know if this is right? It seems to produce the byte codes that I have shown, which the preverifier is complaining about. Should it not place enough NOP opcodes and then carry on copying the code from the invoke virtual?
Cheers for the help.
I have found even more. The problem seems to stem from the fact that insertGap in codeIterator doesn't nescessarily insert a gap of the gapLength but will insert a gap of gapLength + 3 if an alignment expcetion is thrown. An alignment exception is thrown because my code has a switch statement in it. Thus when the original code would have been overwritten it is not because there is a gap of 4 rather than 1.
Hope this helps.
I'm having a similar problem. Has this issue been solved??