From 8dea7e903558730c661b06f7e0c589e7a7e98409 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 8 Jan 2018 19:56:47 +0300 Subject: [PATCH] Fix reporting error on calling async method from native method --- .../java/org/teavm/jso/impl/JSClassProcessor.java | 12 +++++++++--- .../org/teavm/jso/impl/JSObjectClassTransformer.java | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java index aaf290d3f..48d45c0da 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java @@ -192,13 +192,19 @@ class JSClassProcessor { Set methods = new HashSet<>(); findInheritedMethods(cls, methods, new HashSet<>()); for (MethodHolder method : cls.getMethods()) { - if (methods.contains(method.getDescriptor()) && method.getAnnotations().get(Sync.class.getName()) == null) { - AnnotationHolder annot = new AnnotationHolder(Sync.class.getName()); - method.getAnnotations().add(annot); + if (methods.contains(method.getDescriptor())) { + makeSync(method); } } } + static void makeSync(MethodHolder method) { + if (method.getAnnotations().get(Sync.class.getName()) == null) { + AnnotationHolder annot = new AnnotationHolder(Sync.class.getName()); + method.getAnnotations().add(annot); + } + } + private void findInheritedMethods(ClassReader cls, Set methods, Set visited) { if (!visited.add(cls.getName())) { return; diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java index d075aa618..d49446202 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java @@ -155,6 +155,8 @@ class JSObjectClassTransformer implements ClassHolderTransformer { basicBlock.add(exit); classHolder.addMethod(exportedMethod); + MethodHolder methodToCall = classHolder.getMethod(method); + JSClassProcessor.makeSync(methodToCall != null ? methodToCall : exportedMethod); String publicAlias = classToExpose.methods.get(method); AnnotationHolder annot = new AnnotationHolder(JSMethodToExpose.class.getName());