✨ Throw an exception when trying to parse a static method with the @CommandMethod annotation
This commit is contained in:
parent
f8235a4ed1
commit
e241420ee9
2 changed files with 8 additions and 1 deletions
|
|
@ -49,6 +49,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -243,6 +244,12 @@ public final class AnnotationParser<C> {
|
|||
method.getName()
|
||||
));
|
||||
}
|
||||
if (Modifier.isStatic(method.getModifiers())) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"@CommandMethod annotated method '%s' is static! @CommandMethod annotated methods should not be static.",
|
||||
method.getName()
|
||||
));
|
||||
}
|
||||
commandMethodPairs.add(new CommandMethodPair(method, commandMethod));
|
||||
}
|
||||
final Collection<Command<C>> commands = this.construct(instance, commandMethodPairs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue