diff --git a/core/src/main/java/org/teavm/dependency/DependencyNode.java b/core/src/main/java/org/teavm/dependency/DependencyNode.java index b478ea7c2..1bb4d1b0a 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyNode.java +++ b/core/src/main/java/org/teavm/dependency/DependencyNode.java @@ -120,10 +120,14 @@ public class DependencyNode implements ValueDependencyInfo { } int j = 0; + boolean copied = false; for (int i = 0; i < newTypes.length; ++i) { DependencyType type = newTypes[i]; if (addType(type) && filter(type)) { newTypes[j++] = type; + } else if (!copied) { + copied = true; + newTypes = newTypes.clone(); } } if (j == 0) { diff --git a/core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java b/core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java index d5418a0c5..9eb7abf1f 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java +++ b/core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java @@ -51,10 +51,13 @@ class DependencyNodeToNodeTransition implements DependencyConsumer { void consume(DependencyType[] types) { int j = 0; + boolean copied = false; for (DependencyType type : types) { + boolean added = false; if (filterType(type)) { if (!destination.hasType(type)) { types[j++] = type; + added = true; } if (type.getName().startsWith("[")) { @@ -65,6 +68,10 @@ class DependencyNodeToNodeTransition implements DependencyConsumer { source.getClassValueNode().connect(destination.getClassValueNode()); } } + if (!added && !copied) { + copied = true; + types = types.clone(); + } } if (j == 0) {