diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java index 92a18b5e7..7df10fbee 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java @@ -689,4 +689,4 @@ public class WasmTarget implements TeaVMTarget { return new VirtualTableProvider(classes, virtualMethods); } -} +} \ No newline at end of file diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmDependencyListener.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmDependencyListener.java index dfb21fd15..522660888 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmDependencyListener.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmDependencyListener.java @@ -20,6 +20,7 @@ import org.teavm.dependency.DependencyAgent; import org.teavm.dependency.MethodDependency; import org.teavm.diagnostics.Diagnostics; import org.teavm.interop.DelegateTo; +import org.teavm.interop.Export; import org.teavm.model.AnnotationReader; import org.teavm.model.CallLocation; import org.teavm.model.ClassHolder; @@ -31,6 +32,19 @@ import org.teavm.model.MethodHolder; import org.teavm.model.MethodReader; public class WasmDependencyListener extends AbstractDependencyListener implements ClassHolderTransformer { + + @Override + public void classReached(DependencyAgent agent, String className, CallLocation location) { + super.classReached(agent, className, location); + + for (MethodReader reader : agent.getClassSource().get(className).getMethods()) { + AnnotationReader annotation = reader.getAnnotations().get(Export.class.getName()); + if (annotation != null) { + agent.linkMethod(reader.getReference(), null).use(); + } + } + } + @Override public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { AnnotationReader delegateAnnot = method.getMethod().getAnnotations().get(DelegateTo.class.getName()); @@ -57,4 +71,4 @@ public class WasmDependencyListener extends AbstractDependencyListener implement } } } -} +} \ No newline at end of file diff --git a/core/src/main/java/org/teavm/dependency/DependencyChecker.java b/core/src/main/java/org/teavm/dependency/DependencyChecker.java index 9d743e888..da8ed4647 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyChecker.java +++ b/core/src/main/java/org/teavm/dependency/DependencyChecker.java @@ -575,4 +575,4 @@ public class DependencyChecker implements DependencyInfo { public void addBootstrapMethodSubstitutor(MethodReference method, BootstrapMethodSubstitutor substitutor) { bootstrapMethodSubstitutors.put(method, substitutor); } -} +} \ No newline at end of file