aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/core/AnnotationProcessor.java25
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldDefaults.java2
2 files changed, 14 insertions, 13 deletions
diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java
index 04448ecb..89dfa555 100644
--- a/src/core/lombok/core/AnnotationProcessor.java
+++ b/src/core/lombok/core/AnnotationProcessor.java
@@ -49,7 +49,7 @@ import lombok.patcher.ClassRootFinder;
@SupportedAnnotationTypes("*")
public class AnnotationProcessor extends AbstractProcessor {
-
+
private static String trace(Throwable t) {
StringWriter w = new StringWriter();
t.printStackTrace(new PrintWriter(w, true));
@@ -65,7 +65,7 @@ public class AnnotationProcessor extends AbstractProcessor {
private final List<ProcessorDescriptor> registered = Arrays.asList(new JavacDescriptor(), new EcjDescriptor());
private final List<ProcessorDescriptor> active = new ArrayList<ProcessorDescriptor>();
private final List<String> delayedWarnings = new ArrayList<String>();
-
+
/**
* This method is a simplified version of {@link lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment}
* It simply returns the processing environment, but in case of gradle incremental compilation,
@@ -73,34 +73,35 @@ public class AnnotationProcessor extends AbstractProcessor {
*/
public static ProcessingEnvironment getJavacProcessingEnvironment(ProcessingEnvironment procEnv, List<String> delayedWarnings) {
ProcessingEnvironment javacProcEnv = tryRecursivelyObtainJavacProcessingEnvironment(procEnv);
-
+
if (javacProcEnv == null) {
- delayedWarnings.add("Can't get the delegate of the gradle IncrementalProcessingEnvironment.");
+ if (!procEnv.getClass().getName().startsWith("org.eclipse.jdt.")) {
+ delayedWarnings.add("Can't get the delegate of the gradle IncrementalProcessingEnvironment.");
+ }
}
-
+
return javacProcEnv;
}
-
+
private static ProcessingEnvironment tryRecursivelyObtainJavacProcessingEnvironment(ProcessingEnvironment procEnv) {
if (procEnv.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) {
return procEnv;
}
-
+
for (Class<?> procEnvClass = procEnv.getClass(); procEnvClass != null; procEnvClass = procEnvClass.getSuperclass()) {
try {
Field field = procEnvClass.getDeclaredField("delegate");
field.setAccessible(true);
Object delegate = field.get(procEnv);
-
+
return tryRecursivelyObtainJavacProcessingEnvironment((ProcessingEnvironment) delegate);
} catch (final Exception e) {
// no valid delegate, try superclass
}
}
-
+
return null;
}
-
static class JavacDescriptor extends ProcessorDescriptor {
private Processor processor;
@@ -111,9 +112,9 @@ public class AnnotationProcessor extends AbstractProcessor {
@Override boolean want(ProcessingEnvironment procEnv, List<String> delayedWarnings) {
ProcessingEnvironment javacProcEnv = getJavacProcessingEnvironment(procEnv, delayedWarnings);
-
+
if (javacProcEnv == null) return false;
-
+
try {
ClassLoader classLoader = findAndPatchClassLoader(javacProcEnv);
processor = (Processor) Class.forName("lombok.javac.apt.LombokProcessor", false, classLoader).newInstance();
diff --git a/src/core/lombok/javac/handlers/HandleFieldDefaults.java b/src/core/lombok/javac/handlers/HandleFieldDefaults.java
index 52f6c39c..aa381c0d 100644
--- a/src/core/lombok/javac/handlers/HandleFieldDefaults.java
+++ b/src/core/lombok/javac/handlers/HandleFieldDefaults.java
@@ -44,7 +44,7 @@ import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
/**
- * Handles the {@code lombok.FieldDefaults} annotation for eclipse.
+ * Handles the {@code lombok.FieldDefaults} annotation for javac.
*/
@ProviderFor(JavacASTVisitor.class)
@HandlerPriority(-2048) //-2^11; to ensure @Value picks up on messing with the fields' 'final' state, run earlier.