diff --git a/classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java b/classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java index 5bcf2d7d9..376b6b9b7 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/ServiceLoaderSupport.java @@ -62,9 +62,11 @@ public class ServiceLoaderSupport extends AbstractDependencyListener implements writer.append(", "); } String implName = implementations.get(i); - writer.append("[").appendClass(implName).append(", ").appendMethodBody( - new MethodReference(implName, new MethodDescriptor("", ValueType.VOID))) - .append("]"); + if (context.getClassSource().getClassNames().contains(implName)) { + writer.append("[").appendClass(implName).append(", ").appendMethodBody( + new MethodReference(implName, new MethodDescriptor("", ValueType.VOID))) + .append("]"); + } } writer.append("];").softNewLine(); }