Annotation processing in Eclipse
Gilles Duboscq
duboscq at ssw.jku.at
Wed Feb 12 03:13:03 PST 2014
Hi,
Currently, JMH's annotation processor can not run inside a recent
version of Eclipse (I tested with 4.3.1) and I suppose the same goes
for ecj.
This is because JMH seems to rely on javac's toString implementation
for PackageElements. In eclipse they seem to return something like
"package a.b.c".
While building the microbenchmarks in Eclipse is probably not the
canonical way of using JMH, maybe a simple fix along these lines would
help make it possible (an potentially makes JMH more robust against
future changes in javac):
diff -r 4495c91bdaf4
jmh-core/src/main/java/org/openjdk/jmh/processor/internal/AnnUtils.java
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/AnnUtils.java
Tue Feb 11 22:54:59 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/AnnUtils.java
Wed Feb 12 12:09:30 2014 +0100
@@ -26,6 +26,7 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import java.lang.annotation.Annotation;
@@ -58,7 +59,7 @@
while (walk.getKind() != ElementKind.PACKAGE) {
walk = walk.getEnclosingElement();
}
- return walk.toString();
+ return ((PackageElement) walk).getQualifiedName().toString();
}
/**
-Gilles
More information about the jmh-dev
mailing list