classlib: fix support of null string in System.out/err streams

This commit is contained in:
Alexey Andreev 2024-08-17 20:48:38 +02:00
parent 199032d48a
commit 8dd344412e

View File

@ -22,6 +22,9 @@ import org.teavm.jso.JSBody;
public class JSStdoutPrintStream extends JsConsolePrintStream { public class JSStdoutPrintStream extends JsConsolePrintStream {
@Override @Override
public void print(String s) { public void print(String s) {
if (s == null) {
s = "null";
}
if (PlatformDetector.isWebAssemblyGC()) { if (PlatformDetector.isWebAssemblyGC()) {
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
WasmGCSupport.putCharStdout(s.charAt(i)); WasmGCSupport.putCharStdout(s.charAt(i));