src/share/classes/com/sun/tools/javac/Main.java

Thu, 21 Feb 2013 17:49:56 -0800

author
lana
date
Thu, 21 Feb 2013 17:49:56 -0800
changeset 1603
6118072811e5
parent 1590
011cf7e0a148
child 1934
c7dcf899ffff
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.javac;
    28 import java.io.PrintWriter;
    29 import java.lang.reflect.*;
    32 /**
    33  * The programmatic interface for the Java Programming Language
    34  * compiler, javac.
    35  *
    36  * <p>Except for the two methods
    37  * {@link #compile(java.lang.String[])}
    38  * {@link #compile(java.lang.String[],java.io.PrintWriter)},
    39  * nothing described in this source file is part of any supported
    40  * API.  If you write code that depends on this, you do so at your own
    41  * risk.  This code and its internal interfaces are subject to change
    42  * or deletion without notice.
    43  */
    44 @jdk.Supported
    45 public class Main {
    47     /** Unsupported command line interface.
    48      * @param args   The command line parameters.
    49      */
    50     public static void main(String[] args) throws Exception {
    51       if (args.length > 0 && args[0].equals("-Xjdb")) {
    52         String[] newargs = new String[args.length + 2];
    53         Class<?> c = Class.forName("com.sun.tools.example.debug.tty.TTY");
    54         Method method = c.getDeclaredMethod ("main", new Class<?>[] {args.getClass()});
    55         method.setAccessible(true);
    56         System.arraycopy(args, 1, newargs, 3, args.length - 1);
    57         newargs[0] = "-connect";
    58         newargs[1] = "com.sun.jdi.CommandLineLaunch:options=-esa -ea:com.sun.tools...";
    59         newargs[2] = "com.sun.tools.javac.Main";
    60         method.invoke(null, new Object[] { newargs });
    61       } else {
    62         System.exit(compile(args));
    63       }
    64     }
    66     /** Programmatic interface to the Java Programming Language
    67      * compiler, javac.
    68      *
    69      * @param args The command line arguments that would normally be
    70      * passed to the javac program as described in the man page.
    71      * @return an integer equivalent to the exit value from invoking
    72      * javac, see the man page for details.
    73      */
    74     public static int compile(String[] args) {
    75         com.sun.tools.javac.main.Main compiler =
    76             new com.sun.tools.javac.main.Main("javac");
    77         return compiler.compile(args).exitCode;
    78     }
    82     /** Programmatic interface to the Java Programming Language
    83      * compiler, javac.
    84      *
    85      * @param args The command line arguments that would normally be
    86      * passed to the javac program as described in the man page.
    87      * @param out PrintWriter to which the compiler's diagnostic
    88      * output is directed.
    89      * @return an integer equivalent to the exit value from invoking
    90      * javac, see the man page for details.
    91      */
    92     public static int compile(String[] args, PrintWriter out) {
    93         com.sun.tools.javac.main.Main compiler =
    94             new com.sun.tools.javac.main.Main("javac", out);
    95         return compiler.compile(args).exitCode;
    96     }
    97 }

mercurial