aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2018-04-17 04:19:37 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2018-04-17 04:19:37 +0200
commitf540335ef972d84f02efba6dcaf608aec0e19129 (patch)
tree90b3c96253dc86171c6e948739a95ddc431e91b6 /src/core/lombok/javac
parent7e81ac623831c3147e8fba4ca4ebfa021f4f5bd5 (diff)
downloadlombok-f540335ef972d84f02efba6dcaf608aec0e19129.tar.gz
lombok-f540335ef972d84f02efba6dcaf608aec0e19129.tar.bz2
lombok-f540335ef972d84f02efba6dcaf608aec0e19129.zip
[Fixes #1656] Lombok would silently do the wrong thing when using references to `public static final String` fields, instead of actual string literals, there where you can specify strings in lombok annotation parameters, such as `@ToString(of = MyClass.CONSTANT_FIELD)`. We can’t really fix it, but at least now lombok will error when you do that and describe in detail what’s going wrong.
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/JavacAST.java2
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index 12d919af..4ca2c050 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -396,7 +396,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
oldSource = log.useSource(newSource);
if (pos == null) pos = astObject.pos();
}
- if (pos != null && attemptToRemoveErrorsInRange) {
+ if (pos != null && node != null && attemptToRemoveErrorsInRange) {
removeFromDeferredDiagnostics(pos.getStartPosition(), node.getEndPosition(pos));
}
try {
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index fda1a5d2..1976548c 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -360,7 +360,10 @@ public class JavacHandlerUtil {
expressions.add(inner);
if (inner instanceof JCAnnotation) {
try {
- guesses.add(createAnnotation((Class<A>) Class.forName(inner.type.toString()), (JCAnnotation) inner, node));
+ @SuppressWarnings("unchecked")
+ Class<A> innerClass = (Class<A>) Class.forName(inner.type.toString());
+
+ guesses.add(createAnnotation(innerClass, (JCAnnotation) inner, node));
} catch (ClassNotFoundException ex) {
throw new IllegalStateException(ex);
}