From f540335ef972d84f02efba6dcaf608aec0e19129 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 17 Apr 2018 04:19:37 +0200 Subject: [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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/lombok/javac/JavacAST.java | 2 +- src/core/lombok/javac/handlers/JavacHandlerUtil.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/lombok/javac') 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 { 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) Class.forName(inner.type.toString()), (JCAnnotation) inner, node)); + @SuppressWarnings("unchecked") + Class innerClass = (Class) Class.forName(inner.type.toString()); + + guesses.add(createAnnotation(innerClass, (JCAnnotation) inner, node)); } catch (ClassNotFoundException ex) { throw new IllegalStateException(ex); } -- cgit