diff options
23 files changed, 52 insertions, 52 deletions
diff --git a/src/core/lombok/core/configuration/NullCheckExceptionType.java b/src/core/lombok/core/configuration/NullCheckExceptionType.java index 7c30d297..c4bb71f2 100644 --- a/src/core/lombok/core/configuration/NullCheckExceptionType.java +++ b/src/core/lombok/core/configuration/NullCheckExceptionType.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 The Project Lombok Authors. + * Copyright (C) 2014-2018 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ package lombok.core.configuration; public enum NullCheckExceptionType { ILLEGAL_ARGUMENT_EXCEPTION { public String toExceptionMessage(String fieldName) { - return fieldName + " is null"; + return fieldName + " is marked @NonNull but is null"; } @Override public String getExceptionType() { @@ -35,7 +35,7 @@ public enum NullCheckExceptionType { }, NULL_POINTER_EXCEPTION { @Override public String toExceptionMessage(String fieldName) { - return fieldName + " is marked as @NonNull but is null"; + return fieldName + " is marked @NonNull but is null"; } public String getExceptionType() { diff --git a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java index dd4ce12f..2e09b2df 100644 --- a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java +++ b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java @@ -26,16 +26,16 @@ class ConstructorsWithAccessorsNonNull { @java.lang.SuppressWarnings("all") public ConstructorsWithAccessorsNonNull(@lombok.NonNull final Integer plower, @lombok.NonNull final Integer upper, @lombok.NonNull final Integer huh, @lombok.NonNull final Integer _huh2) { if (plower == null) { - throw new java.lang.NullPointerException("plower"); + throw new java.lang.NullPointerException("plower is marked @NonNull but is null"); } if (upper == null) { - throw new java.lang.NullPointerException("upper"); + throw new java.lang.NullPointerException("upper is marked @NonNull but is null"); } if (huh == null) { - throw new java.lang.NullPointerException("huh"); + throw new java.lang.NullPointerException("huh is marked @NonNull but is null"); } if (_huh2 == null) { - throw new java.lang.NullPointerException("_huh2"); + throw new java.lang.NullPointerException("_huh2 is marked @NonNull but is null"); } this.plower = plower; this.pUpper = upper; diff --git a/test/transform/resource/after-delombok/DataOnLocalClass.java b/test/transform/resource/after-delombok/DataOnLocalClass.java index 84817897..d611490b 100644 --- a/test/transform/resource/after-delombok/DataOnLocalClass.java +++ b/test/transform/resource/after-delombok/DataOnLocalClass.java @@ -64,7 +64,7 @@ class DataOnLocalClass2 { @java.lang.SuppressWarnings("all") public InnerLocal(@lombok.NonNull final String name) { if (name == null) { - throw new java.lang.NullPointerException("name"); + throw new java.lang.NullPointerException("name is marked @NonNull but is null"); } this.name = name; } @@ -76,7 +76,7 @@ class DataOnLocalClass2 { @java.lang.SuppressWarnings("all") public void setName(@lombok.NonNull final String name) { if (name == null) { - throw new java.lang.NullPointerException("name"); + throw new java.lang.NullPointerException("name is marked @NonNull but is null"); } this.name = name; } diff --git a/test/transform/resource/after-delombok/NonNullOnParameter.java b/test/transform/resource/after-delombok/NonNullOnParameter.java index a27d19c9..fa06e41b 100644 --- a/test/transform/resource/after-delombok/NonNullOnParameter.java +++ b/test/transform/resource/after-delombok/NonNullOnParameter.java @@ -2,22 +2,22 @@ class NonNullOnParameter extends Thread { NonNullOnParameter(@lombok.NonNull String arg) { this(arg, ""); if (arg == null) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } } NonNullOnParameter(@lombok.NonNull String arg, @lombok.NonNull String arg2) { super(arg); if (arg2 == null) { - throw new java.lang.NullPointerException("arg2"); + throw new java.lang.NullPointerException("arg2 is marked @NonNull but is null"); } if (arg == null) throw new NullPointerException(); } public void test2(@lombok.NonNull String arg, @lombok.NonNull String arg2, @lombok.NonNull String arg3) { if (arg == null) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } if (arg3 == null) { - throw new java.lang.NullPointerException("arg3"); + throw new java.lang.NullPointerException("arg3 is marked @NonNull but is null"); } if (arg2 == null) { throw new NullPointerException("arg2"); @@ -26,21 +26,21 @@ class NonNullOnParameter extends Thread { } public void test3(@lombok.NonNull String arg) { if (arg == null) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } if (arg != null) throw new IllegalStateException(); } public void test(@lombok.NonNull String stringArg, @lombok.NonNull String arg2, @lombok.NonNull int primitiveArg) { if (stringArg == null) { - throw new java.lang.NullPointerException("stringArg"); + throw new java.lang.NullPointerException("stringArg is marked @NonNull but is null"); } if (arg2 == null) { - throw new java.lang.NullPointerException("arg2"); + throw new java.lang.NullPointerException("arg2 is marked @NonNull but is null"); } } public void test(@lombok.NonNull String arg) { if (arg == null) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } System.out.println("Hey"); if (arg == null) throw new NullPointerException(); diff --git a/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java index 62fd878a..a2dcb49c 100644 --- a/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java +++ b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java @@ -1,7 +1,7 @@ abstract class NonNullOnParameterAbstract { public void test(@lombok.NonNull String arg) { if (arg == null) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } System.out.println("Hey"); } diff --git a/test/transform/resource/after-delombok/NonNullOnParameterOfDefaultMethod.java b/test/transform/resource/after-delombok/NonNullOnParameterOfDefaultMethod.java index e220296f..cf10253b 100644 --- a/test/transform/resource/after-delombok/NonNullOnParameterOfDefaultMethod.java +++ b/test/transform/resource/after-delombok/NonNullOnParameterOfDefaultMethod.java @@ -3,7 +3,7 @@ interface NonNullOnParameterOfDefaultMethod { void test(@lombok.NonNull String arg); default void test2(@lombok.NonNull String arg) { if (arg == null) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } System.out.println(arg); } diff --git a/test/transform/resource/after-delombok/NonNullPlain.java b/test/transform/resource/after-delombok/NonNullPlain.java index f6b8037e..d3de3dcf 100644 --- a/test/transform/resource/after-delombok/NonNullPlain.java +++ b/test/transform/resource/after-delombok/NonNullPlain.java @@ -13,7 +13,7 @@ class NonNullPlain { @java.lang.SuppressWarnings("all") public NonNullPlain(@lombok.NonNull final int i, @lombok.NonNull final String s) { if (s == null) { - throw new java.lang.NullPointerException("s"); + throw new java.lang.NullPointerException("s is marked @NonNull but is null"); } this.i = i; this.s = s; @@ -39,7 +39,7 @@ class NonNullPlain { @java.lang.SuppressWarnings("all") public void setS(@lombok.NonNull final String s) { if (s == null) { - throw new java.lang.NullPointerException("s"); + throw new java.lang.NullPointerException("s is marked @NonNull but is null"); } this.s = s; } diff --git a/test/transform/resource/after-delombok/NonNullWithAlternateException.java b/test/transform/resource/after-delombok/NonNullWithAlternateException.java index 76c6406a..982da7d8 100644 --- a/test/transform/resource/after-delombok/NonNullWithAlternateException.java +++ b/test/transform/resource/after-delombok/NonNullWithAlternateException.java @@ -3,14 +3,14 @@ public class NonNullWithAlternateException { private String test; public void testMethod(@lombok.NonNull String arg) { if (arg == null) { - throw new java.lang.IllegalArgumentException("arg is null"); + throw new java.lang.IllegalArgumentException("arg is marked @NonNull but is null"); } System.out.println(arg); } @java.lang.SuppressWarnings("all") public void setTest(@lombok.NonNull final String test) { if (test == null) { - throw new java.lang.IllegalArgumentException("test is null"); + throw new java.lang.IllegalArgumentException("test is marked @NonNull but is null"); } this.test = test; } diff --git a/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java b/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java index 97de0d8a..5000f16d 100644 --- a/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java +++ b/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java @@ -2,7 +2,7 @@ class NonNullWithSneakyThrows { void test(@lombok.NonNull String in) { try { if (in == null) { - throw new java.lang.NullPointerException("in"); + throw new java.lang.NullPointerException("in is marked @NonNull but is null"); } System.out.println(in); } catch (final java.lang.Throwable $ex) { diff --git a/test/transform/resource/after-delombok/SetterOnClass.java b/test/transform/resource/after-delombok/SetterOnClass.java index f2347bcb..f880e20b 100644 --- a/test/transform/resource/after-delombok/SetterOnClass.java +++ b/test/transform/resource/after-delombok/SetterOnClass.java @@ -54,7 +54,7 @@ class SetterOnClass6 { @java.lang.SuppressWarnings("all") public void setNonNull(@lombok.NonNull final String nonNull) { if (nonNull == null) { - throw new java.lang.NullPointerException("nonNull"); + throw new java.lang.NullPointerException("nonNull is marked @NonNull but is null"); } this.nonNull = nonNull; } diff --git a/test/transform/resource/after-delombok/WitherOnClass.java b/test/transform/resource/after-delombok/WitherOnClass.java index 45d0c4b5..93309c89 100644 --- a/test/transform/resource/after-delombok/WitherOnClass.java +++ b/test/transform/resource/after-delombok/WitherOnClass.java @@ -36,7 +36,7 @@ class WitherOnClass3 { @java.lang.SuppressWarnings("all") public WitherOnClass3 withNonNull(@lombok.NonNull final String nonNull) { if (nonNull == null) { - throw new java.lang.NullPointerException("nonNull"); + throw new java.lang.NullPointerException("nonNull is marked @NonNull but is null"); } return this.nonNull == nonNull ? this : new WitherOnClass3(this.couldBeNull, nonNull); } diff --git a/test/transform/resource/after-ecj/ConstructorsWithAccessors.java b/test/transform/resource/after-ecj/ConstructorsWithAccessors.java index 301e6132..6050ab9f 100644 --- a/test/transform/resource/after-ecj/ConstructorsWithAccessors.java +++ b/test/transform/resource/after-ecj/ConstructorsWithAccessors.java @@ -20,19 +20,19 @@ super(); if ((plower == null)) { - throw new java.lang.NullPointerException("plower"); + throw new java.lang.NullPointerException("plower is marked @NonNull but is null"); } if ((upper == null)) { - throw new java.lang.NullPointerException("upper"); + throw new java.lang.NullPointerException("upper is marked @NonNull but is null"); } if ((huh == null)) { - throw new java.lang.NullPointerException("huh"); + throw new java.lang.NullPointerException("huh is marked @NonNull but is null"); } if ((_huh2 == null)) { - throw new java.lang.NullPointerException("_huh2"); + throw new java.lang.NullPointerException("_huh2 is marked @NonNull but is null"); } this.plower = plower; this.pUpper = upper; diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 341df49b..ff2a3d20 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -64,7 +64,7 @@ class DataOnLocalClass2 { public @java.lang.SuppressWarnings("all") void setName(final @lombok.NonNull String name) { if ((name == null)) { - throw new java.lang.NullPointerException("name"); + throw new java.lang.NullPointerException("name is marked @NonNull but is null"); } this.name = name; } @@ -99,7 +99,7 @@ class DataOnLocalClass2 { super(); if ((name == null)) { - throw new java.lang.NullPointerException("name"); + throw new java.lang.NullPointerException("name is marked @NonNull but is null"); } this.name = name; } diff --git a/test/transform/resource/after-ecj/NonNullOnParameter.java b/test/transform/resource/after-ecj/NonNullOnParameter.java index bbceb153..fde47e1d 100644 --- a/test/transform/resource/after-ecj/NonNullOnParameter.java +++ b/test/transform/resource/after-ecj/NonNullOnParameter.java @@ -3,14 +3,14 @@ class NonNullOnParameter extends Thread { this(arg, ""); if ((arg == null)) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } } NonNullOnParameter(@lombok.NonNull String arg, @lombok.NonNull String arg2) { super(arg); if ((arg2 == null)) { - throw new java.lang.NullPointerException("arg2"); + throw new java.lang.NullPointerException("arg2 is marked @NonNull but is null"); } if ((arg == null)) throw new NullPointerException(); @@ -18,11 +18,11 @@ class NonNullOnParameter extends Thread { public void test2(@lombok.NonNull String arg, @lombok.NonNull String arg2, @lombok.NonNull String arg3) { if ((arg == null)) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } if ((arg3 == null)) { - throw new java.lang.NullPointerException("arg3"); + throw new java.lang.NullPointerException("arg3 is marked @NonNull but is null"); } if ((arg2 == null)) { @@ -34,7 +34,7 @@ class NonNullOnParameter extends Thread { public void test3(@lombok.NonNull String arg) { if ((arg == null)) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } if ((arg != null)) throw new IllegalStateException(); @@ -42,17 +42,17 @@ class NonNullOnParameter extends Thread { public void test(@lombok.NonNull String stringArg, @lombok.NonNull String arg2, @lombok.NonNull int primitiveArg) { if ((stringArg == null)) { - throw new java.lang.NullPointerException("stringArg"); + throw new java.lang.NullPointerException("stringArg is marked @NonNull but is null"); } if ((arg2 == null)) { - throw new java.lang.NullPointerException("arg2"); + throw new java.lang.NullPointerException("arg2 is marked @NonNull but is null"); } } public void test(@lombok.NonNull String arg) { if ((arg == null)) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } System.out.println("Hey"); if ((arg == null)) diff --git a/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java b/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java index a7dae247..d3e1fdd6 100644 --- a/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java +++ b/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java @@ -5,7 +5,7 @@ abstract class NonNullOnParameterAbstract { public void test(@lombok.NonNull String arg) { if ((arg == null)) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } System.out.println("Hey"); } diff --git a/test/transform/resource/after-ecj/NonNullOnParameterOfDefaultMethod.java b/test/transform/resource/after-ecj/NonNullOnParameterOfDefaultMethod.java index 85e99702..7293bcf5 100644 --- a/test/transform/resource/after-ecj/NonNullOnParameterOfDefaultMethod.java +++ b/test/transform/resource/after-ecj/NonNullOnParameterOfDefaultMethod.java @@ -3,7 +3,7 @@ interface NonNullOnParameterOfDefaultMethod { default void test2(@lombok.NonNull String arg) { if ((arg == null)) { - throw new java.lang.NullPointerException("arg"); + throw new java.lang.NullPointerException("arg is marked @NonNull but is null"); } System.out.println(arg); } diff --git a/test/transform/resource/after-ecj/NonNullPlain.java b/test/transform/resource/after-ecj/NonNullPlain.java index 9edb576b..c703f38a 100644 --- a/test/transform/resource/after-ecj/NonNullPlain.java +++ b/test/transform/resource/after-ecj/NonNullPlain.java @@ -9,7 +9,7 @@ import java.lang.annotation.*; super(); if ((s == null)) { - throw new java.lang.NullPointerException("s"); + throw new java.lang.NullPointerException("s is marked @NonNull but is null"); } this.i = i; this.s = s; @@ -29,7 +29,7 @@ import java.lang.annotation.*; public @java.lang.SuppressWarnings("all") void setS(final @lombok.NonNull String s) { if ((s == null)) { - throw new java.lang.NullPointerException("s"); + throw new java.lang.NullPointerException("s is marked @NonNull but is null"); } this.s = s; } diff --git a/test/transform/resource/after-ecj/NonNullWithAlternateException.java b/test/transform/resource/after-ecj/NonNullWithAlternateException.java index 8a547ecf..39e9c0a8 100644 --- a/test/transform/resource/after-ecj/NonNullWithAlternateException.java +++ b/test/transform/resource/after-ecj/NonNullWithAlternateException.java @@ -6,14 +6,14 @@ public class NonNullWithAlternateException { public void testMethod(@lombok.NonNull String arg) { if ((arg == null)) { - throw new java.lang.IllegalArgumentException("arg is null"); + throw new java.lang.IllegalArgumentException("arg is marked @NonNull but is null"); } System.out.println(arg); } public @java.lang.SuppressWarnings("all") void setTest(final @lombok.NonNull String test) { if ((test == null)) { - throw new java.lang.IllegalArgumentException("test is null"); + throw new java.lang.IllegalArgumentException("test is marked @NonNull but is null"); } this.test = test; } diff --git a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java index 1a57be29..22799b5e 100644 --- a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java +++ b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java @@ -7,7 +7,7 @@ class NonNullWithSneakyThrows { { if ((in == null)) { - throw new java.lang.NullPointerException("in"); + throw new java.lang.NullPointerException("in is marked @NonNull but is null"); } System.out.println(in); } diff --git a/test/transform/resource/after-ecj/SetterOnClass.java b/test/transform/resource/after-ecj/SetterOnClass.java index aa3459bb..c7aec900 100644 --- a/test/transform/resource/after-ecj/SetterOnClass.java +++ b/test/transform/resource/after-ecj/SetterOnClass.java @@ -64,7 +64,7 @@ public @java.lang.SuppressWarnings("all") void setNonNull(final @lombok.NonNull String nonNull) { if ((nonNull == null)) { - throw new java.lang.NullPointerException("nonNull"); + throw new java.lang.NullPointerException("nonNull is marked @NonNull but is null"); } this.nonNull = nonNull; } diff --git a/test/transform/resource/after-ecj/WitherOnClass.java b/test/transform/resource/after-ecj/WitherOnClass.java index 82132e87..086ba591 100644 --- a/test/transform/resource/after-ecj/WitherOnClass.java +++ b/test/transform/resource/after-ecj/WitherOnClass.java @@ -34,7 +34,7 @@ public @java.lang.SuppressWarnings("all") WitherOnClass3 withNonNull(final @lombok.NonNull String nonNull) { if ((nonNull == null)) { - throw new java.lang.NullPointerException("nonNull"); + throw new java.lang.NullPointerException("nonNull is marked @NonNull but is null"); } return ((this.nonNull == nonNull) ? this : new WitherOnClass3(this.couldBeNull, nonNull)); } diff --git a/website/templates/features/NonNull.html b/website/templates/features/NonNull.html index 28d083d0..3d99a3c7 100644 --- a/website/templates/features/NonNull.html +++ b/website/templates/features/NonNull.html @@ -11,7 +11,7 @@ </p><p> Lombok has always treated any annotation named <code>@NonNull</code> on a field as a signal to generate a null-check if lombok generates an entire method or constructor for you, via for example <a href="/features/Data"><code>@Data</code></a>. Now, however, using lombok's own <code>@lombok.NonNull</code> on a parameter results in the insertion of just the null-check statement inside your own method or constructor. </p><p> - The null-check looks like <code>if (param == null) throw new NullPointerException("param");</code> and will be inserted at the very top of your method. For constructors, the null-check will be inserted immediately following any explicit <code>this()</code> or <code>super()</code> calls. + The null-check looks like <code>if (param == null) throw new NullPointerException("param is marked @NonNull but is null");</code> and will be inserted at the very top of your method. For constructors, the null-check will be inserted immediately following any explicit <code>this()</code> or <code>super()</code> calls. </p><p> If a null-check is already present at the top, no additional null-check will be generated. </p> @@ -23,7 +23,7 @@ <dt> <code>lombok.nonNull.exceptionType</code> = [<code>NullPointerException</code> | <code>IllegalArgumentException</code>] (default: <code>NullPointerException</code>). </dt><dd> - When lombok generates a null-check <code>if</code> statement, by default, a <code>java.lang.NullPointerException</code> will be thrown with the field name as the exception message. However, you can use <code>IllegalArgumentException</code> in this configuration key to have lombok throw that exception, with '<em>fieldName</em> is null' as exception message. + When lombok generates a null-check <code>if</code> statement, by default, a <code>java.lang.NullPointerException</code> will be thrown with '<em>field name</em> is marked @NonNull but is null' as the exception message. However, you can use <code>IllegalArgumentException</code> in this configuration key to have lombok throw that exception with this message instead. </dd><dt> <code>lombok.nonNull.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set) </dt><dd> diff --git a/website/usageExamples/NonNullExample_post.jpage b/website/usageExamples/NonNullExample_post.jpage index 24175e06..bb67b3f6 100644 --- a/website/usageExamples/NonNullExample_post.jpage +++ b/website/usageExamples/NonNullExample_post.jpage @@ -6,7 +6,7 @@ public class NonNullExample extends Something { public NonNullExample(@NonNull Person person) { super("Hello"); if (person == null) { - throw new NullPointerException("person"); + throw new NullPointerException("person is marked @NonNull but is null"); } this.name = person.getName(); } |