aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-04-18 05:44:12 +0200
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-04-18 05:44:12 +0200
commit01702f70d063b7c7685f8c4de94e6d1718047390 (patch)
tree26b19a8be43bb14997186c82e8e9315b50ca738b /src/core/lombok
parent1a1527028cdd23905915ce0b93c5102ccbd67b99 (diff)
downloadlombok-01702f70d063b7c7685f8c4de94e6d1718047390.tar.gz
lombok-01702f70d063b7c7685f8c4de94e6d1718047390.tar.bz2
lombok-01702f70d063b7c7685f8c4de94e6d1718047390.zip
[StandardException] generate an error if the annotation is on a class that extends nothing.
Diffstat (limited to 'src/core/lombok')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleStandardException.java8
-rw-r--r--src/core/lombok/javac/handlers/HandleStandardException.java6
2 files changed, 13 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleStandardException.java b/src/core/lombok/eclipse/handlers/HandleStandardException.java
index 1a2542f4..def6e495 100755
--- a/src/core/lombok/eclipse/handlers/HandleStandardException.java
+++ b/src/core/lombok/eclipse/handlers/HandleStandardException.java
@@ -48,7 +48,13 @@ public class HandleStandardException extends EclipseAnnotationHandler<StandardEx
EclipseNode typeNode = annotationNode.up();
if (!isClass(typeNode)) {
- annotationNode.addError("@StandardException is only supported on a class.");
+ annotationNode.addError("@StandardException is only supported on a class");
+ return;
+ }
+
+ TypeDeclaration classDef = (TypeDeclaration) typeNode.get();
+ if (classDef.superclass == null) {
+ annotationNode.addError("@StandardException requires that you extend a Throwable type");
return;
}
diff --git a/src/core/lombok/javac/handlers/HandleStandardException.java b/src/core/lombok/javac/handlers/HandleStandardException.java
index 39913a90..ea1a0c5c 100644
--- a/src/core/lombok/javac/handlers/HandleStandardException.java
+++ b/src/core/lombok/javac/handlers/HandleStandardException.java
@@ -59,6 +59,12 @@ public class HandleStandardException extends JavacAnnotationHandler<StandardExce
return;
}
+ JCClassDecl classDef = (JCClassDecl) typeNode.get();
+ if (classDef.extending == null) {
+ annotationNode.addError("@StandardException requires that you extend a Throwable type");
+ return;
+ }
+
AccessLevel access = annotation.getInstance().access();
if (access == null) access = AccessLevel.PUBLIC;
if (access == AccessLevel.NONE) {