From c9e9e3654a85280426da90eb878829a2f28ef1b5 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 23 Jun 2015 19:17:32 +0400 Subject: [PATCH] Fix dependency error in some programs that use annotation API --- .../lang/reflect/AnnotationDependencyListener.java | 10 ++++++++++ .../main/java/org/teavm/jso/plugin/FunctorImpl.java | 2 +- .../org/teavm/platform/plugin/PlatformGenerator.java | 2 -- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/reflect/AnnotationDependencyListener.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/reflect/AnnotationDependencyListener.java index 406598ca3..856377276 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/reflect/AnnotationDependencyListener.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/reflect/AnnotationDependencyListener.java @@ -139,5 +139,15 @@ public class AnnotationDependencyListener extends AbstractDependencyListener { agent.linkClass(className, location); } } + + if (method.getMethod().hasModifier(ElementModifier.STATIC) && + method.getMethod().getName().equals("$$__readAnnotations__$$")) { + ClassReader cls = agent.getClassSource().get(method.getReference().getClassName()); + if (cls != null) { + for (AnnotationReader annotation : cls.getAnnotations().all()) { + agent.linkClass(annotation.getType(), location); + } + } + } } } diff --git a/teavm-jso/src/main/java/org/teavm/jso/plugin/FunctorImpl.java b/teavm-jso/src/main/java/org/teavm/jso/plugin/FunctorImpl.java index 1f51130f4..198291c0a 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/plugin/FunctorImpl.java +++ b/teavm-jso/src/main/java/org/teavm/jso/plugin/FunctorImpl.java @@ -24,7 +24,7 @@ import java.lang.annotation.Target; * * @author Alexey Andreev */ -@Retention(RetentionPolicy.RUNTIME) +@Retention(RetentionPolicy.CLASS) @Target(ElementType.TYPE) @interface FunctorImpl { String value(); diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java index 5e3306692..300e0f66f 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformGenerator.java @@ -60,8 +60,6 @@ public class PlatformGenerator implements Generator, Injector, DependencyPlugin case "getCurrentThread": method.getResult().propagate(agent.getType("java.lang.Thread")); break; - case "getAnnotations": - method.getResult(); } }