fix: improved InsnSequence

This commit is contained in:
zaaarf 2023-03-04 12:01:39 +01:00
parent c9ea715ba1
commit faa59bd7de
No known key found for this signature in database
GPG key ID: AD8563472FD43386

View file

@ -26,7 +26,7 @@ public class InsnSequence extends InsnList {
*/ */
public InsnSequence(AbstractInsnNode node) { public InsnSequence(AbstractInsnNode node) {
super(); super();
super.add(node); this.add(node);
} }
/** /**
@ -39,7 +39,7 @@ public class InsnSequence extends InsnList {
Objects.requireNonNull(startNode); Objects.requireNonNull(startNode);
Objects.requireNonNull(endNode); Objects.requireNonNull(endNode);
for(; startNode != endNode && startNode != null; startNode = startNode.getNext()) for(; startNode != endNode && startNode != null; startNode = startNode.getNext())
super.add(startNode); this.add(startNode);
if (startNode == null) if (startNode == null)
throw new InstructionMismatchException("Nodes" + getFirst() + " and " + getLast() + " are not connected."); throw new InstructionMismatchException("Nodes" + getFirst() + " and " + getLast() + " are not connected.");
} }
@ -69,12 +69,13 @@ public class InsnSequence extends InsnList {
} }
/** /**
* Wraps InsnList's add() to ignore null values. * Wraps InsnList's add() to throw an exception
* when fed null values.
* @param node to add * @param node to add
*/ */
@Override @Override
public void add(AbstractInsnNode node) { public void add(AbstractInsnNode node) {
if(node != null) Objects.requireNonNull(node);
super.add(node); super.add(node);
} }