< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java

Print this page
rev 2988 : JDK-8058150

@@ -31,10 +31,11 @@
 import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
 import java.util.regex.*;
+import java.util.stream.Collectors;
 
 import javax.annotation.processing.*;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
 import javax.lang.model.util.*;

@@ -55,19 +56,22 @@
 import com.sun.tools.javac.comp.Env;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.platform.PlatformProvider;
+import com.sun.tools.javac.platform.PlatformProvider.PluginInfo;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.Abort;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Convert;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.Iterators;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.MatchingUtils;

@@ -280,11 +284,23 @@
                  */
                 processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader",
                         processorClassLoaderException);
             }
         }
-        discoveredProcs = new DiscoveredProcessors(processorIterator);
+        PlatformProvider platformProvider = context.get(PlatformProvider.class);
+        java.util.List<Processor> platformProcessors = Collections.emptyList();
+        if (platformProvider != null) {
+            platformProcessors = platformProvider.getAnnotationProcessors()
+                                                 .stream()
+                                                 .map(ap -> ap.getPlugin())
+                                                 .collect(Collectors.toList());
+        }
+        List<Iterator<? extends Processor>> iterators = List.of(processorIterator,
+                                                                platformProcessors.iterator());
+        Iterator<? extends Processor> compoundIterator =
+                Iterators.createCompoundIterator(iterators, i -> i);
+        discoveredProcs = new DiscoveredProcessors(compoundIterator);
     }
 
     /**
      * Returns an empty processor iterator if no processors are on the
      * relevant path, otherwise if processors are present, logs an

@@ -479,10 +495,18 @@
                 }
                 tempOptions.put(candidateKey, candidateValue);
             }
         }
 
+        PlatformProvider platformProvider = context.get(PlatformProvider.class);
+
+        if (platformProvider != null) {
+            for (PluginInfo<Processor> ap : platformProvider.getAnnotationProcessors()) {
+                tempOptions.putAll(ap.getOptions());
+            }
+        }
+
         return Collections.unmodifiableMap(tempOptions);
     }
 
     private Set<String> initUnmatchedProcessorOptions() {
         Set<String> unmatchedProcessorOptions = new HashSet<>();
< prev index next >