0N/A/*
815N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.javac;
0N/A
0N/Aimport java.io.PrintWriter;
0N/Aimport java.lang.reflect.*;
0N/A
0N/A
0N/A/**
0N/A * The programmatic interface for the Java Programming Language
0N/A * compiler, javac.
0N/A *
0N/A * <p>Except for the two methods
0N/A * {@link #compile(java.lang.String[])}
0N/A * {@link #compile(java.lang.String[],java.io.PrintWriter)},
0N/A * nothing described in this source file is part of any supported
0N/A * API. If you write code that depends on this, you do so at your own
0N/A * risk. This code and its internal interfaces are subject to change
0N/A * or deletion without notice.
0N/A */
0N/Apublic class Main {
0N/A
0N/A /** Unsupported command line interface.
0N/A * @param args The command line parameters.
0N/A */
0N/A public static void main(String[] args) throws Exception {
0N/A if (args.length > 0 && args[0].equals("-Xjdb")) {
0N/A String[] newargs = new String[args.length + 2];
0N/A Class<?> c = Class.forName("com.sun.tools.example.debug.tty.TTY");
183N/A Method method = c.getDeclaredMethod ("main", new Class<?>[] {args.getClass()});
0N/A method.setAccessible(true);
0N/A System.arraycopy(args, 1, newargs, 3, args.length - 1);
0N/A newargs[0] = "-connect";
0N/A newargs[1] = "com.sun.jdi.CommandLineLaunch:options=-esa -ea:com.sun.tools...";
0N/A newargs[2] = "com.sun.tools.javac.Main";
0N/A method.invoke(null, new Object[] { newargs });
0N/A } else {
0N/A System.exit(compile(args));
0N/A }
0N/A }
0N/A
0N/A /** Programmatic interface to the Java Programming Language
0N/A * compiler, javac.
0N/A *
0N/A * @param args The command line arguments that would normally be
0N/A * passed to the javac program as described in the man page.
0N/A * @return an integer equivalent to the exit value from invoking
0N/A * javac, see the man page for details.
0N/A */
0N/A public static int compile(String[] args) {
0N/A com.sun.tools.javac.main.Main compiler =
0N/A new com.sun.tools.javac.main.Main("javac");
0N/A return compiler.compile(args);
0N/A }
0N/A
0N/A
0N/A
0N/A /** Programmatic interface to the Java Programming Language
0N/A * compiler, javac.
0N/A *
0N/A * @param args The command line arguments that would normally be
0N/A * passed to the javac program as described in the man page.
0N/A * @param out PrintWriter to which the compiler's diagnostic
0N/A * output is directed.
0N/A * @return an integer equivalent to the exit value from invoking
0N/A * javac, see the man page for details.
0N/A */
0N/A public static int compile(String[] args, PrintWriter out) {
0N/A com.sun.tools.javac.main.Main compiler =
0N/A new com.sun.tools.javac.main.Main("javac", out);
0N/A return compiler.compile(args);
0N/A }
0N/A}