aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-08-01 16:22:37 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-08-01 16:22:37 +0200
commit383586c70561ff30e6d0211d1bea23a99c800791 (patch)
tree2f49e44830f06007967299c03a4161ea9ef5e5ac
parent8428be5c680b5b9e89a58a3ea77d134196f52957 (diff)
downloadlombok-383586c70561ff30e6d0211d1bea23a99c800791.tar.gz
lombok-383586c70561ff30e6d0211d1bea23a99c800791.tar.bz2
lombok-383586c70561ff30e6d0211d1bea23a99c800791.zip
There was a bug in the annotation builder for javac, which would trigger exceptions anytime you used a lombok annotation in implicit-value-parameter form (e.g: @Cleanup("release") instead of @Cleanup or @Cleanup(value="release").
Fixes issue #14
-rw-r--r--src/lombok/javac/HandlerLibrary.java5
-rw-r--r--src/lombok/javac/Javac.java15
2 files changed, 16 insertions, 4 deletions
diff --git a/src/lombok/javac/HandlerLibrary.java b/src/lombok/javac/HandlerLibrary.java
index 7253cbaa..ff21bd3f 100644
--- a/src/lombok/javac/HandlerLibrary.java
+++ b/src/lombok/javac/HandlerLibrary.java
@@ -146,6 +146,7 @@ public class HandlerLibrary {
/** Generates an error in the Messager that was used to initialize this HandlerLibrary. */
public void javacError(String message, Throwable t) {
messager.printMessage(Diagnostic.Kind.ERROR, message + (t == null ? "" : (": " + t)));
+ if ( t != null ) t.printStackTrace();
}
/**
@@ -180,7 +181,9 @@ public class HandlerLibrary {
} catch ( AnnotationValueDecodeFail fail ) {
fail.owner.setError(fail.getMessage(), fail.idx);
} catch ( Throwable t ) {
- javacError(String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
+ String sourceName = "(unknown).java";
+ if ( unit != null && unit.sourcefile != null ) sourceName = unit.sourcefile.getName();
+ javacError(String.format("Lombok annotation handler %s failed on " + sourceName, container.handler.getClass()), t);
}
}
diff --git a/src/lombok/javac/Javac.java b/src/lombok/javac/Javac.java
index 2a3727b6..0987d31a 100644
--- a/src/lombok/javac/Javac.java
+++ b/src/lombok/javac/Javac.java
@@ -94,10 +94,19 @@ public class Javac {
final List<DiagnosticPosition> positions = new ArrayList<DiagnosticPosition>();
for ( JCExpression arg : arguments ) {
- JCAssign assign = (JCAssign) arg;
- String mName = assign.lhs.toString();
+ String mName;
+ JCExpression rhs;
+
+ if ( arg instanceof JCAssign ) {
+ JCAssign assign = (JCAssign) arg;
+ mName = assign.lhs.toString();
+ rhs = assign.rhs;
+ } else {
+ rhs = arg;
+ mName = "value";
+ }
+
if ( !mName.equals(name) ) continue;
- JCExpression rhs = assign.rhs;
if ( rhs instanceof JCNewArray ) {
List<JCExpression> elems = ((JCNewArray)rhs).elems;
for ( JCExpression inner : elems ) {