author | ohair |
Tue, 25 May 2010 15:54:51 -0700 | |
changeset 5520 | 86e4b9a9da40 |
parent 1789 | 7ac8c0815000 |
child 8032 | e1aa25ccdabb |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 1999, 2006, 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 |
static { |
|
47 |
ClassLoader loader = Main.class.getClassLoader(); |
|
48 |
if (loader != null) |
|
49 |
loader.setPackageAssertionStatus("com.sun.tools.javac", true); |
|
50 |
} |
|
51 |
||
52 |
/** Unsupported command line interface. |
|
53 |
* @param args The command line parameters. |
|
54 |
*/ |
|
55 |
public static void main(String[] args) throws Exception { |
|
56 |
if (args.length > 0 && args[0].equals("-Xjdb")) { |
|
57 |
String[] newargs = new String[args.length + 2]; |
|
58 |
Class<?> c = Class.forName("com.sun.tools.example.debug.tty.TTY"); |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
10
diff
changeset
|
59 |
Method method = c.getDeclaredMethod ("main", new Class<?>[] {args.getClass()}); |
10 | 60 |
method.setAccessible(true); |
61 |
System.arraycopy(args, 1, newargs, 3, args.length - 1); |
|
62 |
newargs[0] = "-connect"; |
|
63 |
newargs[1] = "com.sun.jdi.CommandLineLaunch:options=-esa -ea:com.sun.tools..."; |
|
64 |
newargs[2] = "com.sun.tools.javac.Main"; |
|
65 |
method.invoke(null, new Object[] { newargs }); |
|
66 |
} else { |
|
67 |
System.exit(compile(args)); |
|
68 |
} |
|
69 |
} |
|
70 |
||
71 |
/** Programmatic interface to the Java Programming Language |
|
72 |
* compiler, javac. |
|
73 |
* |
|
74 |
* @param args The command line arguments that would normally be |
|
75 |
* passed to the javac program as described in the man page. |
|
76 |
* @return an integer equivalent to the exit value from invoking |
|
77 |
* javac, see the man page for details. |
|
78 |
*/ |
|
79 |
public static int compile(String[] args) { |
|
80 |
com.sun.tools.javac.main.Main compiler = |
|
81 |
new com.sun.tools.javac.main.Main("javac"); |
|
82 |
return compiler.compile(args); |
|
83 |
} |
|
84 |
||
85 |
||
86 |
||
87 |
/** Programmatic interface to the Java Programming Language |
|
88 |
* compiler, javac. |
|
89 |
* |
|
90 |
* @param args The command line arguments that would normally be |
|
91 |
* passed to the javac program as described in the man page. |
|
92 |
* @param out PrintWriter to which the compiler's diagnostic |
|
93 |
* output is directed. |
|
94 |
* @return an integer equivalent to the exit value from invoking |
|
95 |
* javac, see the man page for details. |
|
96 |
*/ |
|
97 |
public static int compile(String[] args, PrintWriter out) { |
|
98 |
com.sun.tools.javac.main.Main compiler = |
|
99 |
new com.sun.tools.javac.main.Main("javac", out); |
|
100 |
return compiler.compile(args); |
|
101 |
} |
|
102 |
} |