[StandardExceptions] fix for javac

This commit is contained in:
Reinier Zwitserloot committed 2021-04-18 06:00:33 +02:00
1 parent c4357b03bf
commit 3f6d668f83
2 files changed
+6 -2

No files matched your search

@@ -33,6 +33,7 @@ import lombok.experimental.StandardException;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.delombok.LombokOptionsFactory;
import lombok.javac.Javac;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -57,8 +58,8 @@ public class HandleStandardException extends JavacAnnotationHandler<StandardExce
return;
}
JCClassDecl classDef = (JCClassDecl) typeNode.get();
if (classDef.extending == null) {
JCTree extending = Javac.getExtendsClause((JCClassDecl) typeNode.get());
if (extending == null) {
annotationNode.addError("@StandardException requires that you extend a Throwable type");
return;
}
+3
View File
@@ -260,6 +260,9 @@ public class Javac {
}
}
/**
* In some versions, the field's type is {@code JCTree}, in others it is {@code JCExpression}, which at the JVM level are not the same.
*/
public static JCTree getExtendsClause(JCClassDecl decl) {
try {
return (JCTree) getExtendsClause.invoke(decl);