From 75d06bebbfffdd93fbfab285acdbb81d8fe02df2 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 18 Mar 2021 14:20:29 +0300 Subject: [PATCH] JS: fix bug in compilation of monitorenter instruction --- .../src/main/java/org/teavm/model/util/AsyncMethodFinder.java | 3 ++- tests/src/test/java/org/teavm/vm/VMTest.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java index 5af6ca51c..14c0cf843 100644 --- a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java +++ b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java @@ -161,7 +161,8 @@ public class AsyncMethodFinder { } if (!hasAsyncMethods && methodRef.getClassName().equals("java.lang.Object") - && (methodRef.getName().equals("monitorEnter") || methodRef.getName().equals("monitorExit"))) { + && (methodRef.getName().equals("monitorEnter") || methodRef.getName().equals("monitorExit")) + && methodRef.parameterCount() == 0) { return; } for (CallSite callSite : node.getCallerCallSites()) { diff --git a/tests/src/test/java/org/teavm/vm/VMTest.java b/tests/src/test/java/org/teavm/vm/VMTest.java index b70475803..c1b86ed63 100644 --- a/tests/src/test/java/org/teavm/vm/VMTest.java +++ b/tests/src/test/java/org/teavm/vm/VMTest.java @@ -433,14 +433,14 @@ public class VMTest { public synchronized void doWait() { new Thread(() -> { - synchronized (AsyncClinitClass.this) { + synchronized (this) { notify(); } }).start(); try { Thread.sleep(1); - synchronized (AsyncClinitClass.this) { + synchronized (this) { wait(); } } catch (InterruptedException ie) {