AnalyzerAdapter.visitFrameTypes incorrectly adds Opcodes.TOP after long types
Locals passed to visitFrameTypes can already contain Opcodes.TOP after the long
type. At the same time this method adds Opcodes.TOP in any case - it doesn't
check the next item after the long value.
In this case long local values are processed incorrectly: we can have the
following: .... Opcodes.LONG, Opcodes.TOP, Opcodes.TOP, ...
As a result we can have incorrect mapping with existing locals and get
incorrect stack map info.
The following fix is suggested to resolve this issue:
if (type == Opcodes.LONG || type == Opcodes.DOUBLE) {
if ((i == n - 1) || ((i < n - 1) && (types[i + 1] != Opcodes.TOP))) {
result.add(Opcodes.TOP);
}
}