< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/api/BasicJavacTask.java

Print this page
rev 2973 : JDK-8058150

@@ -27,10 +27,11 @@
 
 import java.util.Collection;
 import java.util.LinkedHashSet;
 import java.util.Locale;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.annotation.processing.Processor;
 import javax.lang.model.element.Element;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;

@@ -44,10 +45,12 @@
 import com.sun.source.util.TaskListener;
 import com.sun.tools.doclint.DocLint;
 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.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;

@@ -169,10 +172,26 @@
     public Context getContext() {
         return context;
     }
 
     public void initPlugins(Set<List<String>> pluginOpts) {
+        PlatformProvider platformProvider = context.get(PlatformProvider.class);
+
+        if (platformProvider != null) {
+            for (PluginInfo<Plugin> pluginDesc : platformProvider.getPlugins()) {
+                java.util.List<String> options =
+                        pluginDesc.getOptions().entrySet().stream()
+                                                          .map(e -> e.getKey() + "=" + e.getValue())
+                                                          .collect(Collectors.toList());
+                try {
+                    pluginDesc.getPlugin().init(this, options.toArray(new String[options.size()]));
+                } catch (RuntimeException ex) {
+                    throw new PropagatedException(ex);
+                }
+            }
+        }
+
         if (pluginOpts.isEmpty())
             return;
 
         Set<List<String>> pluginsToCall = new LinkedHashSet<>(pluginOpts);
         JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context);
< prev index next >