Fix compiler crash when service enumerated in META-INF/service does not exist

This commit is contained in:
Alexey Andreev 2017-11-16 16:16:10 +03:00
parent 07f946e710
commit 2f73272ed7

View File

@ -62,10 +62,12 @@ public class ServiceLoaderSupport extends AbstractDependencyListener implements
writer.append(", "); writer.append(", ");
} }
String implName = implementations.get(i); String implName = implementations.get(i);
if (context.getClassSource().getClassNames().contains(implName)) {
writer.append("[").appendClass(implName).append(", ").appendMethodBody( writer.append("[").appendClass(implName).append(", ").appendMethodBody(
new MethodReference(implName, new MethodDescriptor("<init>", ValueType.VOID))) new MethodReference(implName, new MethodDescriptor("<init>", ValueType.VOID)))
.append("]"); .append("]");
} }
}
writer.append("];").softNewLine(); writer.append("];").softNewLine();
} }
writer.outdent().append("}").softNewLine(); writer.outdent().append("}").softNewLine();