Browse Source

Add more defense in ExtensionAnnotationProcessor (error message if something is wrong)

pull/349/head
Decebal Suiu 5 years ago
parent
commit
4ba6bdc829
  1. 2
      pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java

2
pf4j/src/main/java/org/pf4j/processor/ExtensionAnnotationProcessor.java

@ -95,11 +95,13 @@ public class ExtensionAnnotationProcessor extends AbstractProcessor {
for (Element element : roundEnv.getElementsAnnotatedWith(Extension.class)) { for (Element element : roundEnv.getElementsAnnotatedWith(Extension.class)) {
// check if @Extension is put on class and not on method or constructor // check if @Extension is put on class and not on method or constructor
if (!(element instanceof TypeElement)) { if (!(element instanceof TypeElement)) {
error(element, "Put annotation only on classes (no methods, no fields)");
continue; continue;
} }
// check if class extends/implements an extension point // check if class extends/implements an extension point
if (!isExtension(element.asType())) { if (!isExtension(element.asType())) {
error(element, "%s is not an extension (it doesn't implement ExtensionPoint)", element);
continue; continue;
} }

Loading…
Cancel
Save