Calling add or set on an InsnListIterator throws NullPointerException when at end of list
This applies to version 5.0.3 and but the bug seems to be present in current svn
trunk.
The following code throws a NullPointerException:
public static void main(String[] args)
{
final InsnList insnList = new InsnList();
final LabelNode node = new LabelNode(new Label());
insnList.add(node);
final ListIterator insnIter = insnList.iterator();
assert insnIter.next() != null;
insnIter.add(node); // NPE
// insnIter.set(node); // also causes NPE
}
According to the ListIterator interface, calling add when hasNext() returns
false should still add the element after the last list element.
However here it calls insertBefore(next, o), which tries to access next.prev,
which fails because next is null.