< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java

Print this page
rev 47452 : imported patch jdk-new-asmv6.patch

@@ -632,16 +632,30 @@
             }
             return prev.index;
         }
 
         public void add(Object o) {
+            if (next != null) {
             InsnList.this.insertBefore(next, (AbstractInsnNode) o);
+            } else if (prev != null) {
+                InsnList.this.insert(prev, (AbstractInsnNode) o);
+            } else {
+                InsnList.this.add((AbstractInsnNode) o);
+            }
             prev = (AbstractInsnNode) o;
             remove = null;
         }
 
         public void set(Object o) {
-            InsnList.this.set(next.prev, (AbstractInsnNode) o);
+            if (remove != null) {
+                InsnList.this.set(remove, (AbstractInsnNode) o);
+                if (remove == prev) {
             prev = (AbstractInsnNode) o;
+                } else {
+                    next = (AbstractInsnNode) o;
         }
+            } else {
+                throw new IllegalStateException();
     }
+        }
+    }
 }
< prev index next >