aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/eclipse/handlers/NonNullHandler.java5
-rw-r--r--src/core/lombok/javac/handlers/NonNullHandler.java5
-rw-r--r--test/transform/resource/after-delombok/NonNullOnParameterAbstract.java10
-rw-r--r--test/transform/resource/after-ecj/NonNullOnParameterAbstract.java13
-rw-r--r--test/transform/resource/before/NonNullOnParameterAbstract.java7
-rw-r--r--test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages1
-rw-r--r--test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages1
8 files changed, 43 insertions, 0 deletions
diff --git a/src/core/lombok/eclipse/handlers/NonNullHandler.java b/src/core/lombok/eclipse/handlers/NonNullHandler.java
index 5c58069c..59fda801 100644
--- a/src/core/lombok/eclipse/handlers/NonNullHandler.java
+++ b/src/core/lombok/eclipse/handlers/NonNullHandler.java
@@ -82,6 +82,11 @@ public class NonNullHandler extends EclipseAnnotationHandler<NonNull> {
if (isGenerated(declaration)) return;
+ if (declaration.isAbstract()) {
+ annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method.");
+ return;
+ }
+
// Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter,
// and if they exist, create a new method in the class: 'private static <T> T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and
// wrap all references to it in the super/this to a call to this method.
diff --git a/src/core/lombok/javac/handlers/NonNullHandler.java b/src/core/lombok/javac/handlers/NonNullHandler.java
index 415d6032..392e8390 100644
--- a/src/core/lombok/javac/handlers/NonNullHandler.java
+++ b/src/core/lombok/javac/handlers/NonNullHandler.java
@@ -76,6 +76,11 @@ public class NonNullHandler extends JavacAnnotationHandler<NonNull> {
if (JavacHandlerUtil.isGenerated(declaration)) return;
+ if (declaration.body == null) {
+ annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method.");
+ return;
+ }
+
// Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter,
// and if they exist, create a new method in the class: 'private static <T> T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and
// wrap all references to it in the super/this to a call to this method.
diff --git a/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java
new file mode 100644
index 00000000..e0330bd6
--- /dev/null
+++ b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java
@@ -0,0 +1,10 @@
+abstract class NonNullOnParameterAbstract {
+ public void test(@lombok.NonNull String arg) {
+ if (arg == null) {
+ throw new java.lang.NullPointerException("arg");
+ }
+ System.out.println("Hey");
+ }
+
+ public abstract void test2(@lombok.NonNull String arg);
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java b/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java
new file mode 100644
index 00000000..a7dae247
--- /dev/null
+++ b/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java
@@ -0,0 +1,13 @@
+abstract class NonNullOnParameterAbstract {
+ NonNullOnParameterAbstract() {
+ super();
+ }
+ public void test(@lombok.NonNull String arg) {
+ if ((arg == null))
+ {
+ throw new java.lang.NullPointerException("arg");
+ }
+ System.out.println("Hey");
+ }
+ public abstract void test2(@lombok.NonNull String arg);
+} \ No newline at end of file
diff --git a/test/transform/resource/before/NonNullOnParameterAbstract.java b/test/transform/resource/before/NonNullOnParameterAbstract.java
new file mode 100644
index 00000000..16691184
--- /dev/null
+++ b/test/transform/resource/before/NonNullOnParameterAbstract.java
@@ -0,0 +1,7 @@
+abstract class NonNullOnParameterAbstract {
+ public void test(@lombok.NonNull String arg) {
+ System.out.println("Hey");
+ }
+
+ public abstract void test2(@lombok.NonNull String arg);
+} \ No newline at end of file
diff --git a/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages
new file mode 100644
index 00000000..1ebeea05
--- /dev/null
+++ b/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages
@@ -0,0 +1 @@
+6:36 @NonNull is meaningless on a parameter of an abstract method.
diff --git a/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages
new file mode 100644
index 00000000..48d1508e
--- /dev/null
+++ b/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages
@@ -0,0 +1 @@
+6:154 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file
diff --git a/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages
new file mode 100644
index 00000000..00547171
--- /dev/null
+++ b/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages
@@ -0,0 +1 @@
+9:36 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file