Path: blob/master/src/java.compiler/share/classes/javax/tools/Tool.java
41152 views
/*1* Copyright (c) 2005, 2014, 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 javax.tools;2627import java.util.Set;28import java.io.InputStream;29import java.io.OutputStream;30import javax.lang.model.SourceVersion;3132/**33* Common interface for tools that can be invoked from a program.34* A tool is traditionally a command line program such as a compiler.35* The set of tools available with a platform is defined by the36* vendor.37*38* <p>Tools can be located using {@link39* java.util.ServiceLoader#load(Class)}.40*41* @author Neal M Gafter42* @author Peter von der Ahé43* @author Jonathan Gibbons44* @since 1.645*/46public interface Tool {47/**48* Returns the name of this tool, or an empty string if no name is provided.49*50* @apiNote It is recommended that the name be the same as would be51* used on the command line: for example, "javac", "jar", "jlink".52* @implNote This implementation returns an empty string.53*54* @return the name of this tool55* @since 956*/57default String name() {58return "";59}6061/**62* Run the tool with the given I/O channels and arguments. By63* convention a tool returns 0 for success and nonzero for errors.64* Any diagnostics generated will be written to either {@code out}65* or {@code err} in some unspecified format.66*67* @param in "standard" input; use System.in if null68* @param out "standard" output; use System.out if null69* @param err "standard" error; use System.err if null70* @param arguments arguments to pass to the tool71* @return 0 for success; nonzero otherwise72* @throws NullPointerException if the array of arguments contains73* any {@code null} elements.74*/75int run(InputStream in, OutputStream out, OutputStream err, String... arguments);7677/**78* Returns the source versions of the Java programming language79* supported by this tool.80* @return a set of supported source versions81*/82Set<SourceVersion> getSourceVersions();8384}858687