24 */
25
26 package com.sun.tools.javac.main;
27
28 import java.io.FileNotFoundException;
29 import java.io.IOException;
30 import java.io.PrintWriter;
31 import java.net.URL;
32 import java.nio.file.NoSuchFileException;
33 import java.security.DigestInputStream;
34 import java.security.MessageDigest;
35 import java.security.NoSuchAlgorithmException;
36 import java.util.Set;
37
38 import javax.tools.JavaFileManager;
39
40 import com.sun.tools.javac.api.BasicJavacTask;
41 import com.sun.tools.javac.file.CacheFSInfo;
42 import com.sun.tools.javac.file.BaseFileManager;
43 import com.sun.tools.javac.file.JavacFileManager;
44 import com.sun.tools.javac.processing.AnnotationProcessingError;
45 import com.sun.tools.javac.util.*;
46 import com.sun.tools.javac.util.Log.PrefixKind;
47 import com.sun.tools.javac.util.Log.WriterKind;
48
49 /** This class provides a command line interface to the javac compiler.
50 *
51 * <p><b>This is NOT part of any supported API.
52 * If you write code that depends on this, you do so at your own risk.
53 * This code and its internal interfaces are subject to change or
54 * deletion without notice.</b>
55 */
56 public class Main {
57
58 /** The name of the compiler, for use in diagnostics.
59 */
60 String ownName;
61
62 /** The writer to use for diagnostic output.
63 */
212 if (showClass != null) {
213 if (showClass.equals("showClass")) // no value given for option
214 showClass = "com.sun.tools.javac.Main";
215 showClass(showClass);
216 }
217
218 boolean ok = args.validate();
219 if (!ok || log.nerrors > 0)
220 return Result.CMDERR;
221
222 if (args.isEmpty())
223 return Result.OK;
224
225 // init Depeendencies
226 if (options.isSet("completionDeps")) {
227 Dependencies.GraphDependencies.preRegister(context);
228 }
229
230 // init plugins
231 Set<List<String>> pluginOpts = args.getPluginOpts();
232 if (!pluginOpts.isEmpty()) {
233 BasicJavacTask t = (BasicJavacTask) BasicJavacTask.instance(context);
234 t.initPlugins(pluginOpts);
235 }
236
237 // init JavaCompiler
238 JavaCompiler comp = JavaCompiler.instance(context);
239
240 // init doclint
241 List<String> docLintOpts = args.getDocLintOpts();
242 if (!docLintOpts.isEmpty()) {
243 BasicJavacTask t = (BasicJavacTask) BasicJavacTask.instance(context);
244 t.initDocLint(docLintOpts);
245 }
246
247 if (options.get(Option.XSTDOUT) != null) {
248 // Stdout reassigned - ask compiler to close it when it is done
249 comp.closeables = comp.closeables.prepend(log.getWriter(WriterKind.NOTICE));
250 }
251
252 try {
|
24 */
25
26 package com.sun.tools.javac.main;
27
28 import java.io.FileNotFoundException;
29 import java.io.IOException;
30 import java.io.PrintWriter;
31 import java.net.URL;
32 import java.nio.file.NoSuchFileException;
33 import java.security.DigestInputStream;
34 import java.security.MessageDigest;
35 import java.security.NoSuchAlgorithmException;
36 import java.util.Set;
37
38 import javax.tools.JavaFileManager;
39
40 import com.sun.tools.javac.api.BasicJavacTask;
41 import com.sun.tools.javac.file.CacheFSInfo;
42 import com.sun.tools.javac.file.BaseFileManager;
43 import com.sun.tools.javac.file.JavacFileManager;
44 import com.sun.tools.javac.platform.PlatformProvider;
45 import com.sun.tools.javac.processing.AnnotationProcessingError;
46 import com.sun.tools.javac.util.*;
47 import com.sun.tools.javac.util.Log.PrefixKind;
48 import com.sun.tools.javac.util.Log.WriterKind;
49
50 /** This class provides a command line interface to the javac compiler.
51 *
52 * <p><b>This is NOT part of any supported API.
53 * If you write code that depends on this, you do so at your own risk.
54 * This code and its internal interfaces are subject to change or
55 * deletion without notice.</b>
56 */
57 public class Main {
58
59 /** The name of the compiler, for use in diagnostics.
60 */
61 String ownName;
62
63 /** The writer to use for diagnostic output.
64 */
213 if (showClass != null) {
214 if (showClass.equals("showClass")) // no value given for option
215 showClass = "com.sun.tools.javac.Main";
216 showClass(showClass);
217 }
218
219 boolean ok = args.validate();
220 if (!ok || log.nerrors > 0)
221 return Result.CMDERR;
222
223 if (args.isEmpty())
224 return Result.OK;
225
226 // init Depeendencies
227 if (options.isSet("completionDeps")) {
228 Dependencies.GraphDependencies.preRegister(context);
229 }
230
231 // init plugins
232 Set<List<String>> pluginOpts = args.getPluginOpts();
233 if (!pluginOpts.isEmpty() || context.get(PlatformProvider.class) != null) {
234 BasicJavacTask t = (BasicJavacTask) BasicJavacTask.instance(context);
235 t.initPlugins(pluginOpts);
236 }
237
238 // init JavaCompiler
239 JavaCompiler comp = JavaCompiler.instance(context);
240
241 // init doclint
242 List<String> docLintOpts = args.getDocLintOpts();
243 if (!docLintOpts.isEmpty()) {
244 BasicJavacTask t = (BasicJavacTask) BasicJavacTask.instance(context);
245 t.initDocLint(docLintOpts);
246 }
247
248 if (options.get(Option.XSTDOUT) != null) {
249 // Stdout reassigned - ask compiler to close it when it is done
250 comp.closeables = comp.closeables.prepend(log.getWriter(WriterKind.NOTICE));
251 }
252
253 try {
|