Path: blob/master/src/jdk.compiler/share/classes/com/sun/source/util/Plugin.java
41175 views
/*1* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.source.util;2627import java.util.ServiceLoader;28import javax.tools.StandardLocation;2930/**31* The interface for a javac plug-in.32*33* <p>The javac plug-in mechanism allows a user to specify one or more plug-ins34* on the javac command line, to be started soon after the compilation35* has begun. Plug-ins are identified by a user-friendly name. Each plug-in that36* is started will be passed an array of strings, which may be used to37* provide the plug-in with values for any desired options or other arguments.38*39* <p>Plug-ins are located via a {@link ServiceLoader},40* using the same class path as annotation processors (i.e.41* {@link StandardLocation#ANNOTATION_PROCESSOR_PATH ANNOTATION_PROCESSOR_PATH} or42* {@code -processorpath}).43*44* <p>It is expected that a typical plug-in will simply register a45* {@link TaskListener} to be informed of events during the execution46* of the compilation, and that the rest of the work will be done47* by the task listener.48*49* @since 1.850*/51public interface Plugin {52/**53* Returns the user-friendly name of this plug-in.54* @return the user-friendly name of the plug-in55*/56String getName();5758/**59* Initializes the plug-in for a given compilation task.60* @param task The compilation task that has just been started61* @param args Arguments, if any, for the plug-in62*/63void init(JavacTask task, String... args);6465/**66* Returns whether or not this plugin should be automatically started,67* even if not explicitly specified in the command-line options.68*69* <p>This method will be called by javac for all plugins located by the70* service loader. If the method returns {@code true}, the plugin will be71* {@link #init(JavacTask,String[]) initialized} with an empty array of72* string arguments if it is not otherwise initialized due to an explicit73* command-line option.74*75* @return whether or not this plugin should be automatically started76*/77default boolean autoStart() {78return false;79}80}818283