author | jjh |
Tue, 24 Jan 2012 15:51:44 -0800 | |
changeset 11708 | f83264d62af2 |
parent 11314 | b612aaca08d0 |
child 13631 | dc1212c348f9 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
8623
cc57bd7697a2
6986895: compiler gives misleading message for no input files
jjg
parents:
8036
diff
changeset
|
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.main; |
|
27 |
||
28 |
import java.io.File; |
|
29 |
import java.io.IOException; |
|
30 |
import java.io.PrintWriter; |
|
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
31 |
import java.net.URL; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
32 |
import java.security.DigestInputStream; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
33 |
import java.security.MessageDigest; |
11708
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
34 |
import java.util.Arrays; |
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
35 |
import java.util.Collection; |
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
36 |
import java.util.LinkedHashSet; |
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
37 |
import java.util.Set; |
6721 | 38 |
import javax.tools.JavaFileManager; |
39 |
import javax.tools.JavaFileObject; |
|
40 |
import javax.annotation.processing.Processor; |
|
10 | 41 |
|
42 |
import com.sun.tools.javac.code.Source; |
|
1208 | 43 |
import com.sun.tools.javac.file.CacheFSInfo; |
731
1dd22bdb9ca5
6714364: refactor javac File handling code into new javac.file package
jjg
parents:
10
diff
changeset
|
44 |
import com.sun.tools.javac.file.JavacFileManager; |
10 | 45 |
import com.sun.tools.javac.jvm.Target; |
46 |
import com.sun.tools.javac.util.*; |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
47 |
import com.sun.tools.javac.util.Log.WriterKind; |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
48 |
import com.sun.tools.javac.util.Log.PrefixKind; |
10 | 49 |
import com.sun.tools.javac.processing.AnnotationProcessingError; |
6721 | 50 |
|
11314 | 51 |
import static com.sun.tools.javac.main.Option.*; |
10 | 52 |
|
53 |
/** This class provides a commandline interface to the GJC compiler. |
|
54 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
55 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
56 |
* If you write code that depends on this, you do so at your own risk. |
10 | 57 |
* This code and its internal interfaces are subject to change or |
58 |
* deletion without notice.</b> |
|
59 |
*/ |
|
60 |
public class Main { |
|
61 |
||
62 |
/** The name of the compiler, for use in diagnostics. |
|
63 |
*/ |
|
64 |
String ownName; |
|
65 |
||
66 |
/** The writer to use for diagnostic output. |
|
67 |
*/ |
|
68 |
PrintWriter out; |
|
69 |
||
11052
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
70 |
/** The log to use for diagnostic output. |
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
71 |
*/ |
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
72 |
Log log; |
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
73 |
|
10 | 74 |
/** |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
75 |
* If true, certain errors will cause an exception, such as command line |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
76 |
* arg errors, or exceptions in user provided code. |
10 | 77 |
*/ |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
78 |
boolean apiMode; |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
79 |
|
10 | 80 |
|
81 |
/** Result codes. |
|
82 |
*/ |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
83 |
public enum Result { |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
84 |
OK(0), // Compilation completed with no errors. |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
85 |
ERROR(1), // Completed but reported errors. |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
86 |
CMDERR(2), // Bad command-line arguments |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
87 |
SYSERR(3), // System error or resource exhaustion. |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
88 |
ABNORMAL(4); // Compiler terminated abnormally |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
89 |
|
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
90 |
Result(int exitCode) { |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
91 |
this.exitCode = exitCode; |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
92 |
} |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
93 |
|
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
94 |
public boolean isOK() { |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
95 |
return (exitCode == 0); |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
96 |
} |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
97 |
|
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
98 |
public final int exitCode; |
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
99 |
} |
10 | 100 |
|
11314 | 101 |
private Option[] recognizedOptions = |
102 |
Option.getJavaCompilerOptions().toArray(new Option[0]); |
|
10 | 103 |
|
11314 | 104 |
private OptionHelper optionHelper = new OptionHelper() { |
105 |
@Override |
|
106 |
public String get(Option option) { |
|
107 |
return options.get(option); |
|
108 |
} |
|
109 |
||
110 |
@Override |
|
111 |
public void put(String name, String value) { |
|
112 |
options.put(name, value); |
|
10 | 113 |
} |
114 |
||
11314 | 115 |
@Override |
116 |
public void remove(String name) { |
|
117 |
options.remove(name); |
|
118 |
} |
|
119 |
||
120 |
@Override |
|
121 |
public Log getLog() { |
|
122 |
return log; |
|
123 |
} |
|
124 |
||
125 |
@Override |
|
126 |
public String getOwnName() { |
|
127 |
return ownName; |
|
128 |
} |
|
129 |
||
130 |
@Override |
|
10 | 131 |
public void error(String key, Object... args) { |
132 |
Main.this.error(key, args); |
|
133 |
} |
|
134 |
||
11314 | 135 |
@Override |
10 | 136 |
public void addFile(File f) { |
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
137 |
filenames.add(f); |
10 | 138 |
} |
139 |
||
11314 | 140 |
@Override |
10 | 141 |
public void addClassName(String s) { |
142 |
classnames.append(s); |
|
143 |
} |
|
144 |
||
11314 | 145 |
}; |
10 | 146 |
|
147 |
/** |
|
148 |
* Construct a compiler instance. |
|
149 |
*/ |
|
150 |
public Main(String name) { |
|
151 |
this(name, new PrintWriter(System.err, true)); |
|
152 |
} |
|
153 |
||
154 |
/** |
|
155 |
* Construct a compiler instance. |
|
156 |
*/ |
|
157 |
public Main(String name, PrintWriter out) { |
|
158 |
this.ownName = name; |
|
159 |
this.out = out; |
|
160 |
} |
|
161 |
/** A table of all options that's passed to the JavaCompiler constructor. */ |
|
162 |
private Options options = null; |
|
163 |
||
164 |
/** The list of source files to process |
|
165 |
*/ |
|
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
166 |
public Set<File> filenames = null; // XXX sb protected |
10 | 167 |
|
168 |
/** List of class files names passed on the command line |
|
169 |
*/ |
|
170 |
public ListBuffer<String> classnames = null; // XXX sb protected |
|
171 |
||
172 |
/** Report a usage error. |
|
173 |
*/ |
|
174 |
void error(String key, Object... args) { |
|
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
175 |
if (apiMode) { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
176 |
String msg = log.localize(PrefixKind.JAVAC, key, args); |
10 | 177 |
throw new PropagatedException(new IllegalStateException(msg)); |
178 |
} |
|
179 |
warning(key, args); |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
180 |
log.printLines(PrefixKind.JAVAC, "msg.usage", ownName); |
10 | 181 |
} |
182 |
||
183 |
/** Report a warning. |
|
184 |
*/ |
|
185 |
void warning(String key, Object... args) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
186 |
log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args)); |
10 | 187 |
} |
188 |
||
189 |
public Option getOption(String flag) { |
|
190 |
for (Option option : recognizedOptions) { |
|
191 |
if (option.matches(flag)) |
|
192 |
return option; |
|
193 |
} |
|
194 |
return null; |
|
195 |
} |
|
196 |
||
197 |
public void setOptions(Options options) { |
|
198 |
if (options == null) |
|
199 |
throw new NullPointerException(); |
|
200 |
this.options = options; |
|
201 |
} |
|
202 |
||
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
203 |
public void setAPIMode(boolean apiMode) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
204 |
this.apiMode = apiMode; |
10 | 205 |
} |
206 |
||
207 |
/** Process command line arguments: store all command line options |
|
208 |
* in `options' table and return all source filenames. |
|
209 |
* @param flags The array of command line arguments. |
|
210 |
*/ |
|
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
211 |
public Collection<File> processArgs(String[] flags) { // XXX sb protected |
11708
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
212 |
return processArgs(flags, null); |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
213 |
} |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
214 |
|
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
215 |
public Collection<File> processArgs(String[] flags, String[] classNames) { // XXX sb protected |
10 | 216 |
int ac = 0; |
217 |
while (ac < flags.length) { |
|
218 |
String flag = flags[ac]; |
|
219 |
ac++; |
|
220 |
||
221 |
Option option = null; |
|
222 |
||
223 |
if (flag.length() > 0) { |
|
224 |
// quick hack to speed up file processing: |
|
225 |
// if the option does not begin with '-', there is no need to check |
|
226 |
// most of the compiler options. |
|
227 |
int firstOptionToCheck = flag.charAt(0) == '-' ? 0 : recognizedOptions.length-1; |
|
228 |
for (int j=firstOptionToCheck; j<recognizedOptions.length; j++) { |
|
229 |
if (recognizedOptions[j].matches(flag)) { |
|
230 |
option = recognizedOptions[j]; |
|
231 |
break; |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
if (option == null) { |
|
237 |
error("err.invalid.flag", flag); |
|
238 |
return null; |
|
239 |
} |
|
240 |
||
241 |
if (option.hasArg()) { |
|
242 |
if (ac == flags.length) { |
|
243 |
error("err.req.arg", flag); |
|
244 |
return null; |
|
245 |
} |
|
246 |
String operand = flags[ac]; |
|
247 |
ac++; |
|
11314 | 248 |
if (option.process(optionHelper, flag, operand)) |
10 | 249 |
return null; |
250 |
} else { |
|
11314 | 251 |
if (option.process(optionHelper, flag)) |
10 | 252 |
return null; |
253 |
} |
|
254 |
} |
|
255 |
||
11708
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
256 |
if (this.classnames != null && classNames != null) { |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
257 |
this.classnames.addAll(Arrays.asList(classNames)); |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
258 |
} |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
259 |
|
6721 | 260 |
if (!checkDirectory(D)) |
10 | 261 |
return null; |
6721 | 262 |
if (!checkDirectory(S)) |
10 | 263 |
return null; |
264 |
||
6721 | 265 |
String sourceString = options.get(SOURCE); |
10 | 266 |
Source source = (sourceString != null) |
267 |
? Source.lookup(sourceString) |
|
268 |
: Source.DEFAULT; |
|
6721 | 269 |
String targetString = options.get(TARGET); |
10 | 270 |
Target target = (targetString != null) |
271 |
? Target.lookup(targetString) |
|
272 |
: Target.DEFAULT; |
|
273 |
// We don't check source/target consistency for CLDC, as J2ME |
|
274 |
// profiles are not aligned with J2SE targets; moreover, a |
|
275 |
// single CLDC target may have many profiles. In addition, |
|
276 |
// this is needed for the continued functioning of the JSR14 |
|
277 |
// prototype. |
|
278 |
if (Character.isDigit(target.name.charAt(0))) { |
|
279 |
if (target.compareTo(source.requiredTarget()) < 0) { |
|
280 |
if (targetString != null) { |
|
281 |
if (sourceString == null) { |
|
282 |
warning("warn.target.default.source.conflict", |
|
283 |
targetString, |
|
284 |
source.requiredTarget().name); |
|
285 |
} else { |
|
286 |
warning("warn.source.target.conflict", |
|
287 |
sourceString, |
|
288 |
source.requiredTarget().name); |
|
289 |
} |
|
290 |
return null; |
|
291 |
} else { |
|
2723
b659ca23d5f5
6829189: Java programming with JSR 292 needs language support
jrose
parents:
2212
diff
changeset
|
292 |
target = source.requiredTarget(); |
b659ca23d5f5
6829189: Java programming with JSR 292 needs language support
jrose
parents:
2212
diff
changeset
|
293 |
options.put("-target", target.name); |
10 | 294 |
} |
295 |
} else { |
|
296 |
if (targetString == null && !source.allowGenerics()) { |
|
2723
b659ca23d5f5
6829189: Java programming with JSR 292 needs language support
jrose
parents:
2212
diff
changeset
|
297 |
target = Target.JDK1_4; |
b659ca23d5f5
6829189: Java programming with JSR 292 needs language support
jrose
parents:
2212
diff
changeset
|
298 |
options.put("-target", target.name); |
10 | 299 |
} |
300 |
} |
|
301 |
} |
|
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
302 |
|
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
303 |
// handle this here so it works even if no other options given |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
304 |
String showClass = options.get("showClass"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
305 |
if (showClass != null) { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
306 |
if (showClass.equals("showClass")) // no value given for option |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
307 |
showClass = "com.sun.tools.javac.Main"; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
308 |
showClass(showClass); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
309 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
310 |
|
11052
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
311 |
options.notifyListeners(); |
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
312 |
|
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
313 |
return filenames; |
10 | 314 |
} |
315 |
// where |
|
11314 | 316 |
private boolean checkDirectory(Option option) { |
317 |
String value = options.get(option); |
|
10 | 318 |
if (value == null) |
319 |
return true; |
|
320 |
File file = new File(value); |
|
321 |
if (!file.exists()) { |
|
322 |
error("err.dir.not.found", value); |
|
323 |
return false; |
|
324 |
} |
|
325 |
if (!file.isDirectory()) { |
|
326 |
error("err.file.not.directory", value); |
|
327 |
return false; |
|
328 |
} |
|
329 |
return true; |
|
330 |
} |
|
331 |
||
332 |
/** Programmatic interface for main function. |
|
333 |
* @param args The command line parameters. |
|
334 |
*/ |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
335 |
public Result compile(String[] args) { |
10 | 336 |
Context context = new Context(); |
337 |
JavacFileManager.preRegister(context); // can't create it until Log has been set up |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
338 |
Result result = compile(args, context); |
10 | 339 |
if (fileManager instanceof JavacFileManager) { |
340 |
// A fresh context was created above, so jfm must be a JavacFileManager |
|
341 |
((JavacFileManager)fileManager).close(); |
|
342 |
} |
|
343 |
return result; |
|
344 |
} |
|
345 |
||
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
346 |
public Result compile(String[] args, Context context) { |
10 | 347 |
return compile(args, context, List.<JavaFileObject>nil(), null); |
348 |
} |
|
349 |
||
350 |
/** Programmatic interface for main function. |
|
351 |
* @param args The command line parameters. |
|
352 |
*/ |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
353 |
public Result compile(String[] args, |
10 | 354 |
Context context, |
355 |
List<JavaFileObject> fileObjects, |
|
356 |
Iterable<? extends Processor> processors) |
|
357 |
{ |
|
11708
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
358 |
return compile(args, null, context, fileObjects, processors); |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
359 |
} |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
360 |
|
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
361 |
public Result compile(String[] args, |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
362 |
String[] classNames, |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
363 |
Context context, |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
364 |
List<JavaFileObject> fileObjects, |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
365 |
Iterable<? extends Processor> processors) |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
366 |
{ |
11052
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
367 |
context.put(Log.outKey, out); |
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
368 |
log = Log.instance(context); |
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
369 |
|
10 | 370 |
if (options == null) |
371 |
options = Options.instance(context); // creates a new one |
|
372 |
||
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
373 |
filenames = new LinkedHashSet<File>(); |
10 | 374 |
classnames = new ListBuffer<String>(); |
375 |
JavaCompiler comp = null; |
|
376 |
/* |
|
377 |
* TODO: Logic below about what is an acceptable command line |
|
378 |
* should be updated to take annotation processing semantics |
|
379 |
* into account. |
|
380 |
*/ |
|
381 |
try { |
|
11708
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
382 |
if (args.length == 0 |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
383 |
&& (classNames == null || classNames.length == 0) |
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
384 |
&& fileObjects.isEmpty()) { |
11314 | 385 |
Option.HELP.process(optionHelper, "-help"); |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
386 |
return Result.CMDERR; |
10 | 387 |
} |
388 |
||
10193
3e1ef5e9f4fd
7061125: Proposed javac argument processing performance improvement
jjg
parents:
9071
diff
changeset
|
389 |
Collection<File> files; |
10 | 390 |
try { |
11708
f83264d62af2
7126832: com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
jjh
parents:
11314
diff
changeset
|
391 |
files = processArgs(CommandLine.parse(args), classNames); |
1866 | 392 |
if (files == null) { |
10 | 393 |
// null signals an error in options, abort |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
394 |
return Result.CMDERR; |
1866 | 395 |
} else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) { |
10 | 396 |
// it is allowed to compile nothing if just asking for help or version info |
6721 | 397 |
if (options.isSet(HELP) |
398 |
|| options.isSet(X) |
|
399 |
|| options.isSet(VERSION) |
|
400 |
|| options.isSet(FULLVERSION)) |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
401 |
return Result.OK; |
8623
cc57bd7697a2
6986895: compiler gives misleading message for no input files
jjg
parents:
8036
diff
changeset
|
402 |
if (JavaCompiler.explicitAnnotationProcessingRequested(options)) { |
cc57bd7697a2
6986895: compiler gives misleading message for no input files
jjg
parents:
8036
diff
changeset
|
403 |
error("err.no.source.files.classes"); |
cc57bd7697a2
6986895: compiler gives misleading message for no input files
jjg
parents:
8036
diff
changeset
|
404 |
} else { |
cc57bd7697a2
6986895: compiler gives misleading message for no input files
jjg
parents:
8036
diff
changeset
|
405 |
error("err.no.source.files"); |
cc57bd7697a2
6986895: compiler gives misleading message for no input files
jjg
parents:
8036
diff
changeset
|
406 |
} |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
407 |
return Result.CMDERR; |
10 | 408 |
} |
409 |
} catch (java.io.FileNotFoundException e) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
410 |
warning("err.file.not.found", e.getMessage()); |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
411 |
return Result.SYSERR; |
10 | 412 |
} |
413 |
||
6721 | 414 |
boolean forceStdOut = options.isSet("stdout"); |
10 | 415 |
if (forceStdOut) { |
11052
65b9fa7eaf55
7108668: allow Log to be initialized and used earlier
jjg
parents:
10638
diff
changeset
|
416 |
log.flush(); |
11314 | 417 |
log.setWriters(new PrintWriter(System.out, true)); |
10 | 418 |
} |
419 |
||
1208 | 420 |
// allow System property in following line as a Mustang legacy |
6721 | 421 |
boolean batchMode = (options.isUnset("nonBatchMode") |
1208 | 422 |
&& System.getProperty("nonBatchMode") == null); |
423 |
if (batchMode) |
|
424 |
CacheFSInfo.preRegister(context); |
|
425 |
||
10 | 426 |
fileManager = context.get(JavaFileManager.class); |
427 |
||
428 |
comp = JavaCompiler.instance(context); |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
429 |
if (comp == null) return Result.SYSERR; |
10 | 430 |
|
1866 | 431 |
if (!files.isEmpty()) { |
10 | 432 |
// add filenames to fileObjects |
433 |
comp = JavaCompiler.instance(context); |
|
434 |
List<JavaFileObject> otherFiles = List.nil(); |
|
435 |
JavacFileManager dfm = (JavacFileManager)fileManager; |
|
1866 | 436 |
for (JavaFileObject fo : dfm.getJavaFileObjectsFromFiles(files)) |
10 | 437 |
otherFiles = otherFiles.prepend(fo); |
438 |
for (JavaFileObject fo : otherFiles) |
|
439 |
fileObjects = fileObjects.prepend(fo); |
|
440 |
} |
|
441 |
comp.compile(fileObjects, |
|
442 |
classnames.toList(), |
|
443 |
processors); |
|
444 |
||
1866 | 445 |
if (log.expectDiagKeys != null) { |
7335
8b390fd27190
6900037: javac should warn if earlier -source is used and bootclasspath not set
jjg
parents:
6721
diff
changeset
|
446 |
if (log.expectDiagKeys.isEmpty()) { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
447 |
log.printRawLines("all expected diagnostics found"); |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
448 |
return Result.OK; |
1866 | 449 |
} else { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
450 |
log.printRawLines("expected diagnostic keys not found: " + log.expectDiagKeys); |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
451 |
return Result.ERROR; |
1866 | 452 |
} |
453 |
} |
|
454 |
||
1996 | 455 |
if (comp.errorCount() != 0) |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
456 |
return Result.ERROR; |
10 | 457 |
} catch (IOException ex) { |
458 |
ioMessage(ex); |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
459 |
return Result.SYSERR; |
10 | 460 |
} catch (OutOfMemoryError ex) { |
461 |
resourceMessage(ex); |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
462 |
return Result.SYSERR; |
10 | 463 |
} catch (StackOverflowError ex) { |
464 |
resourceMessage(ex); |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
465 |
return Result.SYSERR; |
10 | 466 |
} catch (FatalError ex) { |
467 |
feMessage(ex); |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
468 |
return Result.SYSERR; |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
469 |
} catch (AnnotationProcessingError ex) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
470 |
if (apiMode) |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
471 |
throw new RuntimeException(ex.getCause()); |
10 | 472 |
apMessage(ex); |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
473 |
return Result.SYSERR; |
10 | 474 |
} catch (ClientCodeException ex) { |
475 |
// as specified by javax.tools.JavaCompiler#getTask |
|
476 |
// and javax.tools.JavaCompiler.CompilationTask#call |
|
477 |
throw new RuntimeException(ex.getCause()); |
|
478 |
} catch (PropagatedException ex) { |
|
479 |
throw ex.getCause(); |
|
480 |
} catch (Throwable ex) { |
|
481 |
// Nasty. If we've already reported an error, compensate |
|
482 |
// for buggy compiler error recovery by swallowing thrown |
|
483 |
// exceptions. |
|
484 |
if (comp == null || comp.errorCount() == 0 || |
|
6721 | 485 |
options == null || options.isSet("dev")) |
10 | 486 |
bugMessage(ex); |
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
487 |
return Result.ABNORMAL; |
10 | 488 |
} finally { |
9071
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
489 |
if (comp != null) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
490 |
try { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
491 |
comp.close(); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
492 |
} catch (ClientCodeException ex) { |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
493 |
throw new RuntimeException(ex.getCause()); |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
494 |
} |
88cd61b4e5aa
6437138: JSR 199: Compiler doesn't diagnose crash in user code
jjg
parents:
8623
diff
changeset
|
495 |
} |
10 | 496 |
filenames = null; |
497 |
options = null; |
|
498 |
} |
|
10638
c8e9604cf151
7075721: javac should have public enum for exit codes
jjg
parents:
10193
diff
changeset
|
499 |
return Result.OK; |
10 | 500 |
} |
501 |
||
502 |
/** Print a message reporting an internal error. |
|
503 |
*/ |
|
504 |
void bugMessage(Throwable ex) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
505 |
log.printLines(PrefixKind.JAVAC, "msg.bug", JavaCompiler.version()); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
506 |
ex.printStackTrace(log.getWriter(WriterKind.NOTICE)); |
10 | 507 |
} |
508 |
||
6581 | 509 |
/** Print a message reporting a fatal error. |
10 | 510 |
*/ |
511 |
void feMessage(Throwable ex) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
512 |
log.printRawLines(ex.getMessage()); |
6721 | 513 |
if (ex.getCause() != null && options.isSet("dev")) { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
514 |
ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE)); |
6581 | 515 |
} |
10 | 516 |
} |
517 |
||
518 |
/** Print a message reporting an input/output error. |
|
519 |
*/ |
|
520 |
void ioMessage(Throwable ex) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
521 |
log.printLines(PrefixKind.JAVAC, "msg.io"); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
522 |
ex.printStackTrace(log.getWriter(WriterKind.NOTICE)); |
10 | 523 |
} |
524 |
||
525 |
/** Print a message reporting an out-of-resources error. |
|
526 |
*/ |
|
527 |
void resourceMessage(Throwable ex) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
528 |
log.printLines(PrefixKind.JAVAC, "msg.resource"); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
529 |
ex.printStackTrace(log.getWriter(WriterKind.NOTICE)); |
10 | 530 |
} |
531 |
||
532 |
/** Print a message reporting an uncaught exception from an |
|
533 |
* annotation processor. |
|
534 |
*/ |
|
535 |
void apMessage(AnnotationProcessingError ex) { |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
536 |
log.printLines("msg.proc.annotation.uncaught.exception"); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
537 |
ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE)); |
10 | 538 |
} |
539 |
||
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
540 |
/** Display the location and checksum of a class. */ |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
541 |
void showClass(String className) { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
542 |
PrintWriter pw = log.getWriter(WriterKind.NOTICE); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
543 |
pw.println("javac: show class: " + className); |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
544 |
URL url = getClass().getResource('/' + className.replace('.', '/') + ".class"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
545 |
if (url == null) |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
546 |
pw.println(" class not found"); |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
547 |
else { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
548 |
pw.println(" " + url); |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
549 |
try { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
550 |
final String algorithm = "MD5"; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
551 |
byte[] digest; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
552 |
MessageDigest md = MessageDigest.getInstance(algorithm); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
553 |
DigestInputStream in = new DigestInputStream(url.openStream(), md); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
554 |
try { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
555 |
byte[] buf = new byte[8192]; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
556 |
int n; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
557 |
do { n = in.read(buf); } while (n > 0); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
558 |
digest = md.digest(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
559 |
} finally { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
560 |
in.close(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
561 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
562 |
StringBuilder sb = new StringBuilder(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
563 |
for (byte b: digest) |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
564 |
sb.append(String.format("%02x", b)); |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
565 |
pw.println(" " + algorithm + " checksum: " + sb); |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
566 |
} catch (Exception e) { |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
567 |
pw.println(" cannot compute digest: " + e); |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
568 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
569 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
570 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
2723
diff
changeset
|
571 |
|
10 | 572 |
private JavaFileManager fileManager; |
573 |
||
574 |
/* ************************************************************************ |
|
575 |
* Internationalization |
|
576 |
*************************************************************************/ |
|
577 |
||
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
578 |
// /** Find a localized string in the resource bundle. |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
579 |
// * @param key The key for the localized string. |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
580 |
// */ |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
581 |
// public static String getLocalizedString(String key, Object... args) { // FIXME sb private |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
582 |
// try { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
583 |
// if (messages == null) |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
584 |
// messages = new JavacMessages(javacBundleName); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
585 |
// return messages.getLocalizedString("javac." + key, args); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
586 |
// } |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
587 |
// catch (MissingResourceException e) { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
588 |
// throw new Error("Fatal Error: Resource for javac is missing", e); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
589 |
// } |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
590 |
// } |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
591 |
// |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
592 |
// public static void useRawMessages(boolean enable) { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
593 |
// if (enable) { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
594 |
// messages = new JavacMessages(javacBundleName) { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
595 |
// @Override |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
596 |
// public String getLocalizedString(String key, Object... args) { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
597 |
// return key; |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
598 |
// } |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
599 |
// }; |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
600 |
// } else { |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
601 |
// messages = new JavacMessages(javacBundleName); |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
602 |
// } |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
603 |
// } |
10 | 604 |
|
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
605 |
public static final String javacBundleName = |
10 | 606 |
"com.sun.tools.javac.resources.javac"; |
11053
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
607 |
// |
48713f779b1d
7108669: cleanup Log methods for direct printing to streams
jjg
parents:
11052
diff
changeset
|
608 |
// private static JavacMessages messages; |
10 | 609 |
} |