From b9d6e29ca2ec6cee42bfc831ad04e243589815b6 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Mon, 9 Jun 2014 18:52:16 +0400 Subject: [PATCH] Tests pass --- .../plugin/ResourceProgramTransformer.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceProgramTransformer.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceProgramTransformer.java index 014433545..798031e2a 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceProgramTransformer.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceProgramTransformer.java @@ -62,7 +62,7 @@ class ResourceProgramTransformer { return Arrays.asList(accessInsn); } ClassReader iface = innerSource.get(method.getClassName()); - if (iface.getAnnotations().get(Resource.class.getName()) == null) { + if (!isSubclass(iface, Resource.class.getName())) { return null; } if (method.getName().startsWith("get")) { @@ -81,6 +81,23 @@ class ResourceProgramTransformer { return null; } + private boolean isSubclass(ClassReader cls, String superClass) { + if (cls.getName().equals(superClass)) { + return true; + } + ClassReader parent = cls.getParent() != null ? innerSource.get(cls.getParent()) : null; + if (parent != null && isSubclass(parent, superClass)) { + return true; + } + for (String ifaceName : cls.getInterfaces()) { + ClassReader iface = innerSource.get(ifaceName); + if (iface != null) { + return isSubclass(iface, superClass); + } + } + return false; + } + private List transformGetterInvocation(InvokeInstruction insn, String property) { if (insn.getReceiver() == null) { return Collections.emptyList();