How to copy InsnList
问题 InsnList has no method for copy self. I tried to iterate list and add each node to new list. But iterating copy of list perform npe private static InsnList copy(InsnList insnList) { InsnList r = new InsnList(); for (int i = 0; i < insnList.size(); i++) r.add(insnList.get(i)); return r; } InsnList copy = copy(someList); for (int i = 0; i < copy.size(); i++) System.out.println(copy.get(i)); I expected that copy will be, but iterating of copy produce follow error Exception in thread "main" java