我有一个单线程应用程序,它遍历一个巨大的树结构,其中子项存储在一个列表中。迭代器总是在一个不可修改的列表上运行:
public List<HierarchyNode> getChildren() {
return Collections.unmodifiableList(children);
}
我仍然在某个时候得到 ConcurrentModificationException,我认为这在不可修改的列表中是不可能的?迭代是使用访问者完成的......任何想法这怎么可能?
编辑:唯一可以修改此列表的是持有该列表的类的构造函数:
private final List<HierarchyNode> children;
也许这与树的内存使用量相当大(> 4GB)有关?
痕迹:
Testcase: testParserSingleFile(General.NetlistBuilder): Caused an ERROR
null
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
at java.util.ArrayList$Itr.next(ArrayList.java:791)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1067)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitArchitectureNode(HierarchyNodeVisitorImplementation.java:20)
at com.bevm.semantics.netlist.NetlistBuilder.visitArchitectureNode(NetlistBuilder.java:40)
at com.bevm.hierarchy.ArchitectureNode.accept(ArchitectureNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitEntityNode(HierarchyNodeVisitorImplementation.java:33)
at com.bevm.semantics.netlist.NetlistBuilder.visitEntityNode(NetlistBuilder.java:33)
at com.bevm.hierarchy.EntityNode.accept(EntityNode.java:33)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitComponentNode(HierarchyNodeVisitorImplementation.java:27)
at com.bevm.hierarchy.ComponentNode.accept(ComponentNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitInstanceNode(HierarchyNodeVisitorImplementation.java:45)
at com.bevm.semantics.netlist.NetlistBuilder.visitInstanceNode(NetlistBuilder.java:85)
at com.bevm.hierarchy.InstanceNode.accept(InstanceNode.java:89)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitArchitectureNode(HierarchyNodeVisitorImplementation.java:21)
at com.bevm.semantics.netlist.NetlistBuilder.visitArchitectureNode(NetlistBuilder.java:40)
at com.bevm.hierarchy.ArchitectureNode.accept(ArchitectureNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitEntityNode(HierarchyNodeVisitorImplementation.java:33)
at com.bevm.semantics.netlist.NetlistBuilder.visitEntityNode(NetlistBuilder.java:33)
at com.bevm.hierarchy.EntityNode.accept(EntityNode.java:33)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitComponentNode(HierarchyNodeVisitorImplementation.java:27)
at com.bevm.hierarchy.ComponentNode.accept(ComponentNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitInstanceNode(HierarchyNodeVisitorImplementation.java:45)
at com.bevm.semantics.netlist.NetlistBuilder.visitInstanceNode(NetlistBuilder.java:85)
at com.bevm.hierarchy.InstanceNode.accept(InstanceNode.java:89)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitArchitectureNode(HierarchyNodeVisitorImplementation.java:21)
at com.bevm.semantics.netlist.NetlistBuilder.visitArchitectureNode(NetlistBuilder.java:40)
at com.bevm.hierarchy.ArchitectureNode.accept(ArchitectureNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitEntityNode(HierarchyNodeVisitorImplementation.java:33)
at com.bevm.semantics.netlist.NetlistBuilder.visitEntityNode(NetlistBuilder.java:33)
at com.bevm.hierarchy.EntityNode.accept(EntityNode.java:33)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitComponentNode(HierarchyNodeVisitorImplementation.java:27)
at com.bevm.hierarchy.ComponentNode.accept(ComponentNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitInstanceNode(HierarchyNodeVisitorImplementation.java:45)
at com.bevm.semantics.netlist.NetlistBuilder.visitInstanceNode(NetlistBuilder.java:85)
at com.bevm.hierarchy.InstanceNode.accept(InstanceNode.java:89)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitGenerateNode(HierarchyNodeVisitorImplementation.java:39)
at com.bevm.semantics.netlist.NetlistBuilder.visitGenerateNode(NetlistBuilder.java:79)
at com.bevm.hierarchy.GenerateNode.accept(GenerateNode.java:27)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitArchitectureNode(HierarchyNodeVisitorImplementation.java:21)
at com.bevm.semantics.netlist.NetlistBuilder.visitArchitectureNode(NetlistBuilder.java:40)
at com.bevm.hierarchy.ArchitectureNode.accept(ArchitectureNode.java:25)
at com.bevm.hierarchy.HierarchyNodeVisitorImplementation.visitEntityNode(HierarchyNodeVisitorImplementation.java:33)
at com.bevm.semantics.netlist.NetlistBuilder.visitEntityNode(NetlistBuilder.java:33)
at com.bevm.hierarchy.EntityNode.accept(EntityNode.java:33)
at com.beckhoff.vmagic.hierarchy.HierarchyNodeVisitorImplementation.visit(HierarchyNodeVisitorImplementation.java:15)
at General.NetlistBuilder.testParserSingleFile(NetlistBuilder.java:125)