author | poonam |
Tue, 26 Feb 2013 08:58:20 -0800 | |
changeset 15808 | c75f11af1033 |
parent 10638 | c8e9604cf151 |
child 16303 | b5dca0b42963 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
8032 | 2 |
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac; |
|
27 |
||
28 |
import java.io.PrintWriter; |
|
29 |
import java.lang.reflect.*; |
|
30 |
||
31 |
||
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 |
public class Main { |
|
45 |
||
46 |
/** Unsupported command line interface. |
|
47 |
* @param args The command line parameters. |
|
48 |
*/ |
|
49 |
public static void main(String[] args) throws Exception { |
|
50 |
if (args.length > 0 && args[0].equals("-Xjdb")) { |
|
51 |
String[] newargs = new String[args.length + 2]; |
|
52 |
Class<?> c = Class.forName("com.sun.tools.example.debug.tty.TTY"); |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
10
diff
changeset
|
53 |
Method method = c.getDeclaredMethod ("main", new Class<?>[] {args.getClass()}); |
10 | 54 |
method.setAccessible(true); |
55 |
System.arraycopy(args, 1, newargs, 3, args.length - 1); |
|
56 |
newargs[0] = "-connect"; |
|
57 |
newargs[1] = "com.sun.jdi.CommandLineLaunch:options=-esa -ea:com.sun.tools..."; |
|
58 |
newargs[2] = "com.sun.tools.javac.Main"; |
|
59 |
method.invoke(null, new Object[] { newargs }); |
|
60 |
} else { |
|
61 |
System.exit(compile(args)); |
|
62 |
} |
|
63 |
} |
|
64 |
||
65 |
/** Programmatic interface to the Java Programming Language |
|
66 |
* compiler, javac. |
|
67 |
* |
|
68 |
* @param args The command line arguments that would normally be |
|
69 |
* passed to the javac program as described in the man page. |
|
70 |
* @return an integer equivalent to the exit value from invoking |
|
71 |
* javac, see the man page for details. |
|
72 |
*/ |
|
73 |
public static int compile(String[] args) { |
|
74 |
com.sun.tools.javac.main.Main compiler = |
|
75 |
new com.sun.tools.javac.main.Main("javac"); |
|
10638 | 76 |
return compiler.compile(args).exitCode; |
10 | 77 |
} |
78 |
||
79 |
||
80 |
||
81 |
/** Programmatic interface to the Java Programming Language |
|
82 |
* compiler, javac. |
|
83 |
* |
|
84 |
* @param args The command line arguments that would normally be |
|
85 |
* passed to the javac program as described in the man page. |
|
86 |
* @param out PrintWriter to which the compiler's diagnostic |
|
87 |
* output is directed. |
|
88 |
* @return an integer equivalent to the exit value from invoking |
|
89 |
* javac, see the man page for details. |
|
90 |
*/ |
|
91 |
public static int compile(String[] args, PrintWriter out) { |
|
92 |
com.sun.tools.javac.main.Main compiler = |
|
93 |
new com.sun.tools.javac.main.Main("javac", out); |
|
10638 | 94 |
return compiler.compile(args).exitCode; |
10 | 95 |
} |
96 |
} |