Path: blob/master/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java
41175 views
/*1* Copyright (c) 1999, 2020, 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.tools.javac;2627import java.io.PrintWriter;2829/**30* A legacy programmatic interface for the Java Programming Language31* compiler, javac.32* See the <a href="{@docRoot}/jdk.compiler/module-summary.html">{@code jdk.compiler}</a>33* module for details on replacement APIs.34*/35public class Main {36/**37* Do not call.38*/39@Deprecated(since="16", forRemoval=true)40public Main(){}4142/** Main entry point for the launcher.43* Note: This method calls System.exit.44* @param args command line arguments45* @throws Exception only if an uncaught internal exception occurs;46* just retained for historical compatibility47*/48public static void main(String[] args) throws Exception {49System.exit(compile(args));50}5152/** Programmatic interface to the Java Programming Language53* compiler, javac.54*55* @param args The command line arguments that would normally be56* passed to the javac program as described in the man page.57* @return an integer equivalent to the exit value from invoking58* javac, see the man page for details.59*/60public static int compile(String[] args) {61com.sun.tools.javac.main.Main compiler =62new com.sun.tools.javac.main.Main("javac");63return compiler.compile(args).exitCode;64}65666768/** Programmatic interface to the Java Programming Language69* compiler, javac.70*71* @param args The command line arguments that would normally be72* passed to the javac program as described in the man page.73* @param out PrintWriter to which the compiler's diagnostic74* output is directed.75* @return an integer equivalent to the exit value from invoking76* javac, see the man page for details.77*/78public static int compile(String[] args, PrintWriter out) {79com.sun.tools.javac.main.Main compiler =80new com.sun.tools.javac.main.Main("javac", out);81return compiler.compile(args).exitCode;82}83}848586