diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java b/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java index c35a347ca..dd4d11195 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java @@ -20,9 +20,20 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.teavm.codegen.SourceWriter; -import org.teavm.dependency.*; +import org.teavm.dependency.AbstractDependencyListener; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyConsumer; +import org.teavm.dependency.DependencyNode; +import org.teavm.dependency.DependencyType; +import org.teavm.dependency.MethodDependency; import org.teavm.javascript.spi.Generator; import org.teavm.javascript.spi.GeneratorContext; import org.teavm.model.CallLocation; @@ -34,7 +45,7 @@ import org.teavm.model.ValueType; * * @author Alexey Andreev */ -public class ServiceLoaderSupport implements Generator, DependencyListener { +public class ServiceLoaderSupport extends AbstractDependencyListener implements Generator { private Set achievedClasses = new HashSet<>(); private Map> serviceMap = new HashMap<>(); private DependencyNode allClassesNode; @@ -84,7 +95,7 @@ public class ServiceLoaderSupport implements Generator, DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { if (!achievedClasses.add(className)) { return; } @@ -123,7 +134,7 @@ public class ServiceLoaderSupport implements Generator, DependencyListener { } @Override - public void methodAchieved(final DependencyAgent agent, MethodDependency method, final CallLocation location) { + public void methodReached(final DependencyAgent agent, MethodDependency method, final CallLocation location) { MethodReference ref = method.getReference(); if (ref.getClassName().equals("java.util.ServiceLoader") && ref.getName().equals("loadServices")) { method.getResult().propagate(agent.getType("[java.lang.Object")); @@ -140,8 +151,4 @@ public class ServiceLoaderSupport implements Generator, DependencyListener { MethodReference ctor = new MethodReference(type, new MethodDescriptor("", ValueType.VOID)); agent.linkMethod(ctor, location).use(); } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } 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 909adaa14..406598ca3 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 @@ -17,9 +17,8 @@ package org.teavm.classlib.java.lang.reflect; import java.util.ArrayList; import java.util.List; +import org.teavm.dependency.AbstractDependencyListener; import org.teavm.dependency.DependencyAgent; -import org.teavm.dependency.DependencyListener; -import org.teavm.dependency.FieldDependency; import org.teavm.dependency.MethodDependency; import org.teavm.model.AccessLevel; import org.teavm.model.AnnotationReader; @@ -41,13 +40,9 @@ import org.teavm.model.emit.ValueEmitter; * * @author Alexey Andreev */ -public class AnnotationDependencyListener implements DependencyListener { +public class AnnotationDependencyListener extends AbstractDependencyListener { @Override - public void started(final DependencyAgent agent) { - } - - @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { ClassReader cls = agent.getClassSource().get(className); if (cls == null) { return; @@ -132,7 +127,7 @@ public class AnnotationDependencyListener implements DependencyListener { } @Override - public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { ValueType type = method.getMethod().getResultType(); while (type instanceof ValueType.Array) { type = ((ValueType.Array)type).getItemType(); @@ -145,8 +140,4 @@ public class AnnotationDependencyListener implements DependencyListener { } } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-core/src/main/java/org/teavm/dependency/AbstractDependencyListener.java b/teavm-core/src/main/java/org/teavm/dependency/AbstractDependencyListener.java new file mode 100644 index 000000000..00cf56fce --- /dev/null +++ b/teavm-core/src/main/java/org/teavm/dependency/AbstractDependencyListener.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dependency; + +import org.teavm.model.CallLocation; + +/** + * + * @author Alexey Andreev + */ +public abstract class AbstractDependencyListener implements DependencyListener { + @Override + public void started(DependencyAgent agent) { + } + + @Override + public void classReached(DependencyAgent agent, String className, CallLocation location) { + } + + @Override + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { + } + + @Override + public void fieldReached(DependencyAgent agent, FieldDependency field, CallLocation location) { + } +} diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java index bc0ebb378..4cf9e6995 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java @@ -219,7 +219,7 @@ public class DependencyChecker implements DependencyInfo { @Override public void run() { for (DependencyListener listener : listeners) { - listener.classAchieved(agent, className, callLocation); + listener.classReached(agent, className, callLocation); } } }); @@ -278,7 +278,7 @@ public class DependencyChecker implements DependencyInfo { MethodDependency graph = methodCache.map(methodRef); if (!graph.isMissing() && added) { for (DependencyListener listener : listeners) { - listener.methodAchieved(agent, graph, callLocation); + listener.methodReached(agent, graph, callLocation); } activateDependencyPlugin(graph, callLocation); } @@ -422,7 +422,7 @@ public class DependencyChecker implements DependencyInfo { } if (!dep.isMissing() && added) { for (DependencyListener listener : listeners) { - listener.fieldAchieved(agent, dep, location); + listener.fieldReached(agent, dep, location); } } return dep; diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyListener.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyListener.java index d7851b3a2..b9ff5a601 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyListener.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyListener.java @@ -24,9 +24,9 @@ import org.teavm.model.CallLocation; public interface DependencyListener { void started(DependencyAgent agent); - void classAchieved(DependencyAgent agent, String className, CallLocation location); + void classReached(DependencyAgent agent, String className, CallLocation location); - void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location); + void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location); - void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location); + void fieldReached(DependencyAgent agent, FieldDependency field, CallLocation location); } diff --git a/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java b/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java index 214c9bbe8..9fa8acd60 100644 --- a/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java +++ b/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java @@ -15,7 +15,10 @@ */ package org.teavm.tooling; -import org.teavm.dependency.*; +import org.teavm.dependency.AbstractDependencyListener; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyNode; +import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; import org.teavm.model.ClassReader; import org.teavm.model.ClassReaderSource; @@ -25,7 +28,7 @@ import org.teavm.model.MethodReference; * * @author Alexey Andreev */ -class TestExceptionDependency implements DependencyListener { +class TestExceptionDependency extends AbstractDependencyListener { private MethodReference getMessageRef = new MethodReference(ExceptionHelper.class, "showException", Throwable.class, String.class); private DependencyNode allClasses; @@ -36,7 +39,7 @@ class TestExceptionDependency implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { if (isException(agent.getClassSource(), className)) { allClasses.propagate(agent.getType(className)); } @@ -57,13 +60,9 @@ class TestExceptionDependency implements DependencyListener { } @Override - public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { if (method.getReference().equals(getMessageRef)) { allClasses.connect(method.getVariable(1)); } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java b/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java index ceb17dd26..c91558fc3 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java @@ -75,14 +75,14 @@ public class EntryPointGenerator extends AbstractRendererListener implements Dep } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { } @Override - public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { } @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { + public void fieldReached(DependencyAgent agent, FieldDependency field, CallLocation location) { } } diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java index 99b9947e0..657f11598 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptBodyDependency.java @@ -20,14 +20,27 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import net.java.html.js.JavaScriptBody; -import org.teavm.dependency.*; -import org.teavm.model.*; +import org.teavm.dependency.AbstractDependencyListener; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyConsumer; +import org.teavm.dependency.DependencyNode; +import org.teavm.dependency.DependencyType; +import org.teavm.dependency.MethodDependency; +import org.teavm.model.AnnotationReader; +import org.teavm.model.AnnotationValue; +import org.teavm.model.CallLocation; +import org.teavm.model.ClassReader; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.ElementModifier; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodReader; +import org.teavm.model.MethodReference; /** * * @author Alexey Andreev */ -public class JavaScriptBodyDependency implements DependencyListener { +public class JavaScriptBodyDependency extends AbstractDependencyListener { private DependencyNode allClassesNode; private Map> achievedMethods = new HashMap<>(); @@ -48,7 +61,7 @@ public class JavaScriptBodyDependency implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { ClassReader cls = agent.getClassSource().get(className); if (cls != null && !cls.hasModifier(ElementModifier.ABSTRACT) && !cls.hasModifier(ElementModifier.INTERFACE)) { @@ -57,7 +70,7 @@ public class JavaScriptBodyDependency implements DependencyListener { } @Override - public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { Set methodsToAchieve = achievedMethods.get(method.getReference()); if (methodsToAchieve != null) { for (MethodReference methodToAchieve : methodsToAchieve) { @@ -105,10 +118,6 @@ public class JavaScriptBodyDependency implements DependencyListener { agent.linkMethod(JavaScriptConvGenerator.valueOfCharMethod, location).use(); } - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency fieldDep, CallLocation location) { - } - private static MethodReader findMethod(ClassReaderSource classSource, String clsName, MethodDescriptor desc) { while (clsName != null) { ClassReader cls = classSource.get(clsName); diff --git a/teavm-jso/src/main/java/org/teavm/jso/plugin/JSODependencyListener.java b/teavm-jso/src/main/java/org/teavm/jso/plugin/JSODependencyListener.java index 29a3b615c..e88b53db2 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/plugin/JSODependencyListener.java +++ b/teavm-jso/src/main/java/org/teavm/jso/plugin/JSODependencyListener.java @@ -19,19 +19,26 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.teavm.dependency.AbstractDependencyListener; import org.teavm.dependency.DependencyAgent; -import org.teavm.dependency.DependencyListener; -import org.teavm.dependency.FieldDependency; import org.teavm.dependency.MethodDependency; import org.teavm.jso.JSMethod; import org.teavm.jso.JSObject; -import org.teavm.model.*; +import org.teavm.model.AnnotationReader; +import org.teavm.model.AnnotationValue; +import org.teavm.model.CallLocation; +import org.teavm.model.ClassReader; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.FieldReader; +import org.teavm.model.FieldReference; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodReader; /** * * @author Alexey Andreev */ -class JSODependencyListener implements DependencyListener { +class JSODependencyListener extends AbstractDependencyListener { private Map exposedClasses = new HashMap<>(); private ClassReaderSource classSource; private DependencyAgent agent; @@ -44,7 +51,7 @@ class JSODependencyListener implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { getExposedClass(className); } @@ -145,12 +152,4 @@ class JSODependencyListener implements DependencyListener { } return addInterfaces(exposedCls, cls); } - - @Override - public void methodAchieved(DependencyAgent agent, MethodDependency methodDep, CallLocation location) { - } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/TestExceptionDependency.java b/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/TestExceptionDependency.java index 363acd8e6..673a6e92e 100644 --- a/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/TestExceptionDependency.java +++ b/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/TestExceptionDependency.java @@ -15,14 +15,21 @@ */ package org.teavm.maven; -import org.teavm.dependency.*; -import org.teavm.model.*; +import org.teavm.dependency.AbstractDependencyListener; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyNode; +import org.teavm.dependency.MethodDependency; +import org.teavm.model.CallLocation; +import org.teavm.model.ClassReader; +import org.teavm.model.ClassReaderSource; +import org.teavm.model.MethodReference; +import org.teavm.model.ValueType; /** * * @author Alexey Andreev */ -class TestExceptionDependency implements DependencyListener { +class TestExceptionDependency extends AbstractDependencyListener { private MethodReference getMessageRef = new MethodReference("java.lang.Throwable", "getMessage", ValueType.object("java.lang.String")); private DependencyNode allClasses; @@ -33,7 +40,7 @@ class TestExceptionDependency implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { if (isException(agent.getClassSource(), className)) { allClasses.propagate(agent.getType(className)); } @@ -54,13 +61,9 @@ class TestExceptionDependency implements DependencyListener { } @Override - public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { if (method.getReference().equals(getMessageRef)) { allClasses.connect(method.getVariable(0)); } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/AnnotationDependencySupport.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/AnnotationDependencySupport.java index 7abe22883..361e645bf 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/AnnotationDependencySupport.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/AnnotationDependencySupport.java @@ -16,12 +16,11 @@ package org.teavm.platform.plugin; import java.lang.annotation.Annotation; +import org.teavm.dependency.AbstractDependencyListener; import org.teavm.dependency.DependencyAgent; import org.teavm.dependency.DependencyConsumer; -import org.teavm.dependency.DependencyListener; import org.teavm.dependency.DependencyNode; import org.teavm.dependency.DependencyType; -import org.teavm.dependency.FieldDependency; import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; import org.teavm.model.MethodReference; @@ -32,7 +31,7 @@ import org.teavm.platform.Platform; * * @author Alexey Andreev */ -public class AnnotationDependencySupport implements DependencyListener { +public class AnnotationDependencySupport extends AbstractDependencyListener { private DependencyNode allClasses; @Override @@ -41,12 +40,12 @@ public class AnnotationDependencySupport implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { allClasses.propagate(agent.getType(className)); } @Override - public void methodAchieved(final DependencyAgent agent, final MethodDependency method, + public void methodReached(final DependencyAgent agent, final MethodDependency method, final CallLocation location) { if (method.getReference().getClassName().equals(Platform.class.getName()) && method.getReference().getName().equals("getAnnotations")) { @@ -61,8 +60,4 @@ public class AnnotationDependencySupport implements DependencyListener { }); } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/ClassLookupDependencySupport.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/ClassLookupDependencySupport.java index dead0e8d9..39b92cc72 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/ClassLookupDependencySupport.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/ClassLookupDependencySupport.java @@ -23,7 +23,7 @@ import org.teavm.platform.Platform; * * @author Alexey Andreev */ -public class ClassLookupDependencySupport implements DependencyListener { +public class ClassLookupDependencySupport extends AbstractDependencyListener { private DependencyNode allClasses; @Override @@ -32,12 +32,12 @@ public class ClassLookupDependencySupport implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { allClasses.propagate(agent.getType(className)); } @Override - public void methodAchieved(final DependencyAgent agent, MethodDependency method, final CallLocation location) { + public void methodReached(final DependencyAgent agent, MethodDependency method, final CallLocation location) { MethodReference ref = method.getReference(); if (ref.getClassName().equals(Platform.class.getName()) && ref.getName().equals("lookupClass")) { allClasses.addConsumer(new DependencyConsumer() { @@ -54,8 +54,4 @@ public class ClassLookupDependencySupport implements DependencyListener { }); } } - - @Override - public void fieldAchieved(DependencyAgent dependencyChecker, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/EnumDependencySupport.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/EnumDependencySupport.java index 92d7c7408..e3b01789e 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/EnumDependencySupport.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/EnumDependencySupport.java @@ -15,15 +15,25 @@ */ package org.teavm.platform.plugin; -import org.teavm.dependency.*; -import org.teavm.model.*; +import org.teavm.dependency.AbstractDependencyListener; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyConsumer; +import org.teavm.dependency.DependencyNode; +import org.teavm.dependency.DependencyType; +import org.teavm.dependency.MethodDependency; +import org.teavm.model.CallLocation; +import org.teavm.model.ClassReader; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodReader; +import org.teavm.model.MethodReference; +import org.teavm.model.ValueType; import org.teavm.platform.Platform; /** * * @author Alexey Andreev */ -public class EnumDependencySupport implements DependencyListener { +public class EnumDependencySupport extends AbstractDependencyListener { private DependencyNode allEnums; @Override @@ -32,7 +42,7 @@ public class EnumDependencySupport implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { ClassReader cls = agent.getClassSource().get(className); if (cls == null || cls.getParent() == null || !cls.getParent().equals("java.lang.Enum")) { return; @@ -41,7 +51,7 @@ public class EnumDependencySupport implements DependencyListener { } @Override - public void methodAchieved(final DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(final DependencyAgent agent, MethodDependency method, CallLocation location) { if (method.getReference().getClassName().equals(Platform.class.getName()) && method.getReference().getName().equals("getEnumConstants")) { allEnums.connect(method.getResult().getArrayItem()); @@ -58,12 +68,8 @@ public class EnumDependencySupport implements DependencyListener { }); method.getResult().propagate(agent.getType("[java.lang.Enum")); for (String cls : agent.getAchievableClasses()) { - classAchieved(agent, cls, location); + classReached(agent, cls, location); } } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/NewInstanceDependencySupport.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/NewInstanceDependencySupport.java index 1a5647b9e..631eefd15 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/NewInstanceDependencySupport.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/NewInstanceDependencySupport.java @@ -23,7 +23,7 @@ import org.teavm.platform.Platform; * * @author Alexey Andreev */ -public class NewInstanceDependencySupport implements DependencyListener { +public class NewInstanceDependencySupport extends AbstractDependencyListener { private DependencyNode allClassesNode; @Override @@ -32,7 +32,7 @@ public class NewInstanceDependencySupport implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { ClassReader cls = agent.getClassSource().get(className); if (cls == null) { return; @@ -47,7 +47,7 @@ public class NewInstanceDependencySupport implements DependencyListener { } @Override - public void methodAchieved(final DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(final DependencyAgent agent, MethodDependency method, CallLocation location) { MethodReader reader = method.getMethod(); if (reader.getOwnerName().equals(Platform.class.getName()) && reader.getName().equals("newInstanceImpl")) { allClassesNode.connect(method.getResult()); @@ -66,8 +66,4 @@ public class NewInstanceDependencySupport implements DependencyListener { methodDep.getVariable(0).propagate(checker.getType(type)); methodDep.use(); } - - @Override - public void fieldAchieved(DependencyAgent dependencyAgent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformDependencyListener.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformDependencyListener.java index 9ff5ad491..1c03bcd3d 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformDependencyListener.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/PlatformDependencyListener.java @@ -15,7 +15,10 @@ */ package org.teavm.platform.plugin; -import org.teavm.dependency.*; +import org.teavm.dependency.AbstractDependencyListener; +import org.teavm.dependency.DependencyAgent; +import org.teavm.dependency.DependencyNode; +import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; import org.teavm.platform.Platform; @@ -23,7 +26,7 @@ import org.teavm.platform.Platform; * * @author Alexey Andreev */ -public class PlatformDependencyListener implements DependencyListener { +public class PlatformDependencyListener extends AbstractDependencyListener { private DependencyNode allClasses; @Override @@ -32,12 +35,12 @@ public class PlatformDependencyListener implements DependencyListener { } @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { + public void classReached(DependencyAgent agent, String className, CallLocation location) { allClasses.propagate(agent.getType(className)); } @Override - public void methodAchieved(final DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(final DependencyAgent agent, MethodDependency method, CallLocation location) { if (!method.getReference().getClassName().equals(Platform.class.getName())) { return; } @@ -47,8 +50,4 @@ public class PlatformDependencyListener implements DependencyListener { break; } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } } diff --git a/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java b/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java index 20e7da06a..c4eaad07c 100644 --- a/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java +++ b/teavm-platform/src/main/java/org/teavm/platform/plugin/ResourceAccessorDependencyListener.java @@ -15,9 +15,8 @@ */ package org.teavm.platform.plugin; +import org.teavm.dependency.AbstractDependencyListener; import org.teavm.dependency.DependencyAgent; -import org.teavm.dependency.DependencyListener; -import org.teavm.dependency.FieldDependency; import org.teavm.dependency.MethodDependency; import org.teavm.model.CallLocation; @@ -25,17 +24,9 @@ import org.teavm.model.CallLocation; * * @author Alexey Andreev */ -class ResourceAccessorDependencyListener implements DependencyListener { +class ResourceAccessorDependencyListener extends AbstractDependencyListener { @Override - public void started(DependencyAgent agent) { - } - - @Override - public void classAchieved(DependencyAgent agent, String className, CallLocation location) { - } - - @Override - public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) { + public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { if (!method.getReference().getClassName().equals(ResourceAccessor.class.getName())) { return; } @@ -45,8 +36,4 @@ class ResourceAccessorDependencyListener implements DependencyListener { break; } } - - @Override - public void fieldAchieved(DependencyAgent agent, FieldDependency field, CallLocation location) { - } }