Plugin.java revision 3170:dc017a37aac5
1184610Salfred/*
2184610Salfred * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
3188412Sthompsa * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4184610Salfred *
5184610Salfred * This code is free software; you can redistribute it and/or modify it
6184610Salfred * under the terms of the GNU General Public License version 2 only, as
7184610Salfred * published by the Free Software Foundation.  Oracle designates this
8184610Salfred * particular file as subject to the "Classpath" exception as provided
9184610Salfred * by Oracle in the LICENSE file that accompanied this code.
10184610Salfred *
11184610Salfred * This code is distributed in the hope that it will be useful, but WITHOUT
12184610Salfred * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13184610Salfred * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14184610Salfred * version 2 for more details (a copy is included in the LICENSE file that
15184610Salfred * accompanied this code).
16184610Salfred *
17184610Salfred * You should have received a copy of the GNU General Public License version
18184610Salfred * 2 along with this work; if not, write to the Free Software Foundation,
19184610Salfred * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20184610Salfred *
21184610Salfred * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22184610Salfred * or visit www.oracle.com if you need additional information or have any
23184610Salfred * questions.
24184610Salfred */
25184610Salfred
26184610Salfredpackage com.sun.source.util;
27226709Syongari
28226709Syongariimport java.util.ServiceLoader;
29226709Syongariimport javax.tools.StandardLocation;
30194677Sthompsa
31194677Sthompsa/**
32226709Syongari * The interface for a javac plug-in.
33226709Syongari *
34194677Sthompsa * <p>The javac plug-in mechanism allows a user to specify one or more plug-ins
35226709Syongari * on the javac command line, to be started soon after the compilation
36226709Syongari * has begun. Plug-ins are identified by a user-friendly name. Each plug-in that
37226709Syongari * is started will be passed an array of strings, which may be used to
38194677Sthompsa * provide the plug-in with values for any desired options or other arguments.
39194677Sthompsa *
40226709Syongari * <p>Plug-ins are located via a {@link ServiceLoader},
41226709Syongari * using the same class path as annotation processors (i.e.
42194677Sthompsa * {@link StandardLocation#ANNOTATION_PROCESSOR_PATH ANNOTATION_PROCESSOR_PATH} or
43194677Sthompsa * {@code -processorpath}).
44194677Sthompsa *
45226709Syongari * <p>It is expected that a typical plug-in will simply register a
46257176Sglebius * {@link TaskListener} to be informed of events during the execution
47226709Syongari * of the compilation, and that the rest of the work will be done
48226709Syongari * by the task listener.
49226709Syongari *
50226709Syongari * @since 1.8
51226709Syongari */
52226709Syongari@jdk.Exported
53226709Syongaripublic interface Plugin {
54226709Syongari    /**
55188942Sthompsa     * Returns the user-friendly name of this plug-in.
56194677Sthompsa     * @return the user-friendly name of the plug-in
57188412Sthompsa     */
58188942Sthompsa    String getName();
59188942Sthompsa
60184610Salfred    /**
61227309Sed     * Initializes the plug-in for a given compilation task.
62227309Sed     * @param task The compilation task that has just been started
63184610Salfred     * @param args Arguments, if any, for the plug-in
64188412Sthompsa     */
65188412Sthompsa    void init(JavacTask task, String... args);
66188412Sthompsa}
67188412Sthompsa