diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java index 026873998..bd748ec4f 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java @@ -56,6 +56,13 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ buffer = new char[capacity]; } + public TAbstractStringBuilder(TString value) { + buffer = new char[value.length()]; + for (int i = 0; i < buffer.length; ++i) { + buffer[i] = value.charAt(i); + } + } + protected TAbstractStringBuilder append(TString string) { if (string == null) { string = TString.wrap("null"); diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TStringBuilder.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TStringBuilder.java index 512e3e599..28a541ea8 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TStringBuilder.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TStringBuilder.java @@ -28,6 +28,10 @@ public class TStringBuilder extends TAbstractStringBuilder implements TAppendabl super(); } + public TStringBuilder(TString value) { + super(value); + } + @Override public TStringBuilder append(TString string) { super.append(string); diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java index 452741005..2317647e0 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java @@ -33,12 +33,21 @@ public class DependencyNode implements ValueDependencyInfo { private volatile String tag; private final AtomicReference arrayItemNode = new AtomicReference<>(); private volatile CountDownLatch arrayItemNodeLatch = new CountDownLatch(1); + private int degree; DependencyNode(DependencyChecker dependencyChecker) { + this(dependencyChecker, 0); + } + + DependencyNode(DependencyChecker dependencyChecker, int degree) { this.dependencyChecker = dependencyChecker; + this.degree = degree; } public void propagate(String type) { + if (degree > 2) { + return; + } if (types.putIfAbsent(type, mapValue) == null) { if (DependencyChecker.shouldLog) { System.out.println(tag + " -> " + type); @@ -75,7 +84,7 @@ public class DependencyNode implements ValueDependencyInfo { public DependencyNode getArrayItem() { DependencyNode result = arrayItemNode.get(); if (result == null) { - result = new DependencyNode(dependencyChecker); + result = new DependencyNode(dependencyChecker, degree + 1); if (arrayItemNode.compareAndSet(null, result)) { if (DependencyChecker.shouldLog) { arrayItemNode.get().tag = tag + "[";