diff --git a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java index 1a55f31dd..706eda6ba 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -225,6 +225,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext private void renderRuntimeString() throws IOException { MethodReference stringCons = new MethodReference(String.class, "", char[].class, void.class); writer.append("function $rt_str(str) {").indent().softNewLine(); + writer.append("if (str===null){").indent().softNewLine(); + writer.append("return null;").softNewLine(); + writer.outdent().append("}").softNewLine(); writer.append("var characters = $rt_createCharArray(str.length);").softNewLine(); writer.append("var charsBuffer = characters.data;").softNewLine(); writer.append("for (var i = 0; i < str.length; i = (i + 1) | 0) {").indent().softNewLine();