From e966690284ca18fb18504baaf62151bfab950973 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 28 Sep 2024 19:58:55 +0200 Subject: [PATCH] Fix failing tests --- .../main/java/org/teavm/classlib/java/lang/TObject.java | 4 ++++ jso/impl/src/main/java/org/teavm/jso/impl/JSOPlugin.java | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java index 7e10519755..27bcabd0c0 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java @@ -186,6 +186,10 @@ final boolean isEmptyMonitor() { if (monitor == null) { return true; } + if (PlatformDetector.isWebAssemblyGC()) { + // TODO: fix Monitor implementation and remove this block + return monitor.owner == null; + } if (monitor.owner == null && (monitor.enteringThreads == null || monitor.enteringThreads.isEmpty()) && (monitor.notifyListeners == null || monitor.notifyListeners.isEmpty())) { diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSOPlugin.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSOPlugin.java index 5ef5e77848..2d62ed1171 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSOPlugin.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSOPlugin.java @@ -31,6 +31,12 @@ public class JSOPlugin implements TeaVMPlugin { @Override public void install(TeaVMHost host) { + var jsHost = host.getExtension(TeaVMJavaScriptHost.class); + var wasmGCHost = host.getExtension(TeaVMWasmGCHost.class); + if (jsHost == null && wasmGCHost == null) { + return; + } + JSBodyRepository repository = new JSBodyRepository(); host.registerService(JSBodyRepository.class, repository); host.add(new JSObjectClassTransformer(repository)); @@ -48,12 +54,10 @@ public void install(TeaVMHost host) { TeaVMPluginUtil.handleNatives(host, JS.class); - var jsHost = host.getExtension(TeaVMJavaScriptHost.class); if (jsHost != null) { installForJS(jsHost); } - var wasmGCHost = host.getExtension(TeaVMWasmGCHost.class); if (wasmGCHost != null) { WasmGCJso.install(host, wasmGCHost, repository); }