From 929e77bf69db2b3697b2ad4f4602ed5176ff4e62 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 25 Feb 2017 19:51:39 +0300 Subject: [PATCH] Postpone execution code after `wait` method, since it's executed in a native callback which can't be async. When the code contains async calls, compiler produces error. --- .../main/java/org/teavm/classlib/java/lang/TObject.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 b4b0fbb47..d6fad8ed6 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 @@ -344,9 +344,11 @@ public class TObject { @Override public void onTimer() { - if (!expired()) { - run(); - } + Platform.postpone(() -> { + if (!expired()) { + run(); + } + }); } @Override