Thu, 24 Jul 2008 19:06:57 +0100
6717241: some diagnostic argument is prematurely converted into a String object
Summary: removed early toString() conversions applied to diagnostic arguments
Reviewed-by: jjg
1 /*
2 * Copyright 1999-2008 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
26 package com.sun.tools.javac.main;
28 import java.io.*;
29 import java.util.HashSet;
30 import java.util.LinkedHashMap;
31 import java.util.Map;
32 import java.util.MissingResourceException;
33 import java.util.ResourceBundle;
34 import java.util.Set;
35 import java.util.logging.Handler;
36 import java.util.logging.Level;
37 import java.util.logging.Logger;
39 import javax.tools.JavaFileManager;
40 import javax.tools.JavaFileObject;
41 import javax.tools.DiagnosticListener;
43 import com.sun.tools.javac.file.JavacFileManager;
44 import com.sun.source.util.TaskEvent;
45 import com.sun.source.util.TaskListener;
47 import com.sun.tools.javac.util.*;
48 import com.sun.tools.javac.code.*;
49 import com.sun.tools.javac.tree.*;
50 import com.sun.tools.javac.parser.*;
51 import com.sun.tools.javac.comp.*;
52 import com.sun.tools.javac.jvm.*;
54 import com.sun.tools.javac.code.Symbol.*;
55 import com.sun.tools.javac.tree.JCTree.*;
57 import com.sun.tools.javac.processing.*;
58 import javax.annotation.processing.Processor;
60 import static javax.tools.StandardLocation.CLASS_OUTPUT;
61 import static com.sun.tools.javac.util.ListBuffer.lb;
63 // TEMP, until we have a more efficient way to save doc comment info
64 import com.sun.tools.javac.parser.DocCommentScanner;
66 import java.util.HashMap;
67 import java.util.Queue;
68 import javax.lang.model.SourceVersion;
70 /** This class could be the main entry point for GJC when GJC is used as a
71 * component in a larger software system. It provides operations to
72 * construct a new compiler, and to run a new compiler on a set of source
73 * files.
74 *
75 * <p><b>This is NOT part of any API supported by Sun Microsystems. If
76 * you write code that depends on this, you do so at your own risk.
77 * This code and its internal interfaces are subject to change or
78 * deletion without notice.</b>
79 */
80 public class JavaCompiler implements ClassReader.SourceCompleter {
81 /** The context key for the compiler. */
82 protected static final Context.Key<JavaCompiler> compilerKey =
83 new Context.Key<JavaCompiler>();
85 /** Get the JavaCompiler instance for this context. */
86 public static JavaCompiler instance(Context context) {
87 JavaCompiler instance = context.get(compilerKey);
88 if (instance == null)
89 instance = new JavaCompiler(context);
90 return instance;
91 }
93 /** The current version number as a string.
94 */
95 public static String version() {
96 return version("release"); // mm.nn.oo[-milestone]
97 }
99 /** The current full version number as a string.
100 */
101 public static String fullVersion() {
102 return version("full"); // mm.mm.oo[-milestone]-build
103 }
105 private static final String versionRBName = "com.sun.tools.javac.resources.version";
106 private static ResourceBundle versionRB;
108 private static String version(String key) {
109 if (versionRB == null) {
110 try {
111 versionRB = ResourceBundle.getBundle(versionRBName);
112 } catch (MissingResourceException e) {
113 return Log.getLocalizedString("version.resource.missing", System.getProperty("java.version"));
114 }
115 }
116 try {
117 return versionRB.getString(key);
118 }
119 catch (MissingResourceException e) {
120 return Log.getLocalizedString("version.unknown", System.getProperty("java.version"));
121 }
122 }
124 private static enum CompilePolicy {
125 /*
126 * Just attribute the parse trees
127 */
128 ATTR_ONLY,
130 /*
131 * Just attribute and do flow analysis on the parse trees.
132 * This should catch most user errors.
133 */
134 CHECK_ONLY,
136 /*
137 * Attribute everything, then do flow analysis for everything,
138 * then desugar everything, and only then generate output.
139 * Means nothing is generated if there are any errors in any classes.
140 */
141 SIMPLE,
143 /*
144 * After attributing everything and doing flow analysis,
145 * group the work by compilation unit.
146 * Then, process the work for each compilation unit together.
147 * Means nothing is generated for a compilation unit if the are any errors
148 * in the compilation unit (or in any preceding compilation unit.)
149 */
150 BY_FILE,
152 /*
153 * Completely process each entry on the todo list in turn.
154 * -- this is the same for 1.5.
155 * Means output might be generated for some classes in a compilation unit
156 * and not others.
157 */
158 BY_TODO;
160 static CompilePolicy decode(String option) {
161 if (option == null)
162 return DEFAULT_COMPILE_POLICY;
163 else if (option.equals("attr"))
164 return ATTR_ONLY;
165 else if (option.equals("check"))
166 return CHECK_ONLY;
167 else if (option.equals("simple"))
168 return SIMPLE;
169 else if (option.equals("byfile"))
170 return BY_FILE;
171 else if (option.equals("bytodo"))
172 return BY_TODO;
173 else
174 return DEFAULT_COMPILE_POLICY;
175 }
176 }
178 private static CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
180 private static enum ImplicitSourcePolicy {
181 /** Don't generate or process implicitly read source files. */
182 NONE,
183 /** Generate classes for implicitly read source files. */
184 CLASS,
185 /** Like CLASS, but generate warnings if annotation processing occurs */
186 UNSET;
188 static ImplicitSourcePolicy decode(String option) {
189 if (option == null)
190 return UNSET;
191 else if (option.equals("none"))
192 return NONE;
193 else if (option.equals("class"))
194 return CLASS;
195 else
196 return UNSET;
197 }
198 }
200 /** The log to be used for error reporting.
201 */
202 public Log log;
204 /** Factory for creating diagnostic objects
205 */
206 JCDiagnostic.Factory diagFactory;
208 /** The tree factory module.
209 */
210 protected TreeMaker make;
212 /** The class reader.
213 */
214 protected ClassReader reader;
216 /** The class writer.
217 */
218 protected ClassWriter writer;
220 /** The module for the symbol table entry phases.
221 */
222 protected Enter enter;
224 /** The symbol table.
225 */
226 protected Symtab syms;
228 /** The language version.
229 */
230 protected Source source;
232 /** The module for code generation.
233 */
234 protected Gen gen;
236 /** The name table.
237 */
238 protected Name.Table names;
240 /** The attributor.
241 */
242 protected Attr attr;
244 /** The attributor.
245 */
246 protected Check chk;
248 /** The flow analyzer.
249 */
250 protected Flow flow;
252 /** The type eraser.
253 */
254 TransTypes transTypes;
256 /** The syntactic sugar desweetener.
257 */
258 Lower lower;
260 /** The annotation annotator.
261 */
262 protected Annotate annotate;
264 /** Force a completion failure on this name
265 */
266 protected final Name completionFailureName;
268 /** Type utilities.
269 */
270 protected Types types;
272 /** Access to file objects.
273 */
274 protected JavaFileManager fileManager;
276 /** Factory for parsers.
277 */
278 protected Parser.Factory parserFactory;
280 /** Optional listener for progress events
281 */
282 protected TaskListener taskListener;
284 /**
285 * Annotation processing may require and provide a new instance
286 * of the compiler to be used for the analyze and generate phases.
287 */
288 protected JavaCompiler delegateCompiler;
290 /**
291 * Flag set if any annotation processing occurred.
292 **/
293 protected boolean annotationProcessingOccurred;
295 /**
296 * Flag set if any implicit source files read.
297 **/
298 protected boolean implicitSourceFilesRead;
300 protected Context context;
302 /** Construct a new compiler using a shared context.
303 */
304 public JavaCompiler(final Context context) {
305 this.context = context;
306 context.put(compilerKey, this);
308 // if fileManager not already set, register the JavacFileManager to be used
309 if (context.get(JavaFileManager.class) == null)
310 JavacFileManager.preRegister(context);
312 names = Name.Table.instance(context);
313 log = Log.instance(context);
314 diagFactory = JCDiagnostic.Factory.instance(context);
315 reader = ClassReader.instance(context);
316 make = TreeMaker.instance(context);
317 writer = ClassWriter.instance(context);
318 enter = Enter.instance(context);
319 todo = Todo.instance(context);
321 fileManager = context.get(JavaFileManager.class);
322 parserFactory = Parser.Factory.instance(context);
324 try {
325 // catch completion problems with predefineds
326 syms = Symtab.instance(context);
327 } catch (CompletionFailure ex) {
328 // inlined Check.completionError as it is not initialized yet
329 log.error("cant.access", ex.sym, ex.getDetailValue());
330 if (ex instanceof ClassReader.BadClassFile)
331 throw new Abort();
332 }
333 source = Source.instance(context);
334 attr = Attr.instance(context);
335 chk = Check.instance(context);
336 gen = Gen.instance(context);
337 flow = Flow.instance(context);
338 transTypes = TransTypes.instance(context);
339 lower = Lower.instance(context);
340 annotate = Annotate.instance(context);
341 types = Types.instance(context);
342 taskListener = context.get(TaskListener.class);
344 reader.sourceCompleter = this;
346 Options options = Options.instance(context);
348 verbose = options.get("-verbose") != null;
349 sourceOutput = options.get("-printsource") != null; // used to be -s
350 stubOutput = options.get("-stubs") != null;
351 relax = options.get("-relax") != null;
352 printFlat = options.get("-printflat") != null;
353 attrParseOnly = options.get("-attrparseonly") != null;
354 encoding = options.get("-encoding");
355 lineDebugInfo = options.get("-g:") == null ||
356 options.get("-g:lines") != null;
357 genEndPos = options.get("-Xjcov") != null ||
358 context.get(DiagnosticListener.class) != null;
359 devVerbose = options.get("dev") != null;
360 processPcks = options.get("process.packages") != null;
362 verboseCompilePolicy = options.get("verboseCompilePolicy") != null;
364 if (attrParseOnly)
365 compilePolicy = CompilePolicy.ATTR_ONLY;
366 else
367 compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
369 implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit"));
371 completionFailureName =
372 (options.get("failcomplete") != null)
373 ? names.fromString(options.get("failcomplete"))
374 : null;
375 }
377 /* Switches:
378 */
380 /** Verbose output.
381 */
382 public boolean verbose;
384 /** Emit plain Java source files rather than class files.
385 */
386 public boolean sourceOutput;
388 /** Emit stub source files rather than class files.
389 */
390 public boolean stubOutput;
392 /** Generate attributed parse tree only.
393 */
394 public boolean attrParseOnly;
396 /** Switch: relax some constraints for producing the jsr14 prototype.
397 */
398 boolean relax;
400 /** Debug switch: Emit Java sources after inner class flattening.
401 */
402 public boolean printFlat;
404 /** The encoding to be used for source input.
405 */
406 public String encoding;
408 /** Generate code with the LineNumberTable attribute for debugging
409 */
410 public boolean lineDebugInfo;
412 /** Switch: should we store the ending positions?
413 */
414 public boolean genEndPos;
416 /** Switch: should we debug ignored exceptions
417 */
418 protected boolean devVerbose;
420 /** Switch: should we (annotation) process packages as well
421 */
422 protected boolean processPcks;
424 /** Switch: is annotation processing requested explitly via
425 * CompilationTask.setProcessors?
426 */
427 protected boolean explicitAnnotationProcessingRequested = false;
429 /**
430 * The policy for the order in which to perform the compilation
431 */
432 protected CompilePolicy compilePolicy;
434 /**
435 * The policy for what to do with implicitly read source files
436 */
437 protected ImplicitSourcePolicy implicitSourcePolicy;
439 /**
440 * Report activity related to compilePolicy
441 */
442 public boolean verboseCompilePolicy;
444 /** A queue of all as yet unattributed classes.
445 */
446 public Todo todo;
448 protected enum CompileState {
449 TODO(0),
450 ATTR(1),
451 FLOW(2);
452 CompileState(int value) {
453 this.value = value;
454 }
455 boolean isDone(CompileState other) {
456 return value >= other.value;
457 }
458 private int value;
459 };
460 protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> {
461 boolean isDone(Env<AttrContext> env, CompileState cs) {
462 CompileState ecs = get(env);
463 return ecs != null && ecs.isDone(cs);
464 }
465 }
466 private CompileStates compileStates = new CompileStates();
468 /** The set of currently compiled inputfiles, needed to ensure
469 * we don't accidentally overwrite an input file when -s is set.
470 * initialized by `compile'.
471 */
472 protected Set<JavaFileObject> inputFiles = new HashSet<JavaFileObject>();
474 /** The number of errors reported so far.
475 */
476 public int errorCount() {
477 if (delegateCompiler != null && delegateCompiler != this)
478 return delegateCompiler.errorCount();
479 else
480 return log.nerrors;
481 }
483 protected final <T> Queue<T> stopIfError(Queue<T> queue) {
484 if (errorCount() == 0)
485 return queue;
486 else
487 return ListBuffer.lb();
488 }
490 protected final <T> List<T> stopIfError(List<T> list) {
491 if (errorCount() == 0)
492 return list;
493 else
494 return List.nil();
495 }
497 /** The number of warnings reported so far.
498 */
499 public int warningCount() {
500 if (delegateCompiler != null && delegateCompiler != this)
501 return delegateCompiler.warningCount();
502 else
503 return log.nwarnings;
504 }
506 /** Whether or not any parse errors have occurred.
507 */
508 public boolean parseErrors() {
509 return parseErrors;
510 }
512 protected Scanner.Factory getScannerFactory() {
513 return Scanner.Factory.instance(context);
514 }
516 /** Try to open input stream with given name.
517 * Report an error if this fails.
518 * @param filename The file name of the input stream to be opened.
519 */
520 public CharSequence readSource(JavaFileObject filename) {
521 try {
522 inputFiles.add(filename);
523 return filename.getCharContent(false);
524 } catch (IOException e) {
525 log.error("error.reading.file", filename, e.getLocalizedMessage());
526 return null;
527 }
528 }
530 /** Parse contents of input stream.
531 * @param filename The name of the file from which input stream comes.
532 * @param input The input stream to be parsed.
533 */
534 protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
535 long msec = now();
536 JCCompilationUnit tree = make.TopLevel(List.<JCTree.JCAnnotation>nil(),
537 null, List.<JCTree>nil());
538 if (content != null) {
539 if (verbose) {
540 printVerbose("parsing.started", filename);
541 }
542 if (taskListener != null) {
543 TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
544 taskListener.started(e);
545 }
546 int initialErrorCount = log.nerrors;
547 Scanner scanner = getScannerFactory().newScanner(content);
548 Parser parser = parserFactory.newParser(scanner, keepComments(), genEndPos);
549 tree = parser.compilationUnit();
550 parseErrors |= (log.nerrors > initialErrorCount);
551 if (lineDebugInfo) {
552 tree.lineMap = scanner.getLineMap();
553 }
554 if (verbose) {
555 printVerbose("parsing.done", Long.toString(elapsed(msec)));
556 }
557 }
559 tree.sourcefile = filename;
561 if (content != null && taskListener != null) {
562 TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, tree);
563 taskListener.finished(e);
564 }
566 return tree;
567 }
568 // where
569 public boolean keepComments = false;
570 protected boolean keepComments() {
571 return keepComments || sourceOutput || stubOutput;
572 }
575 /** Parse contents of file.
576 * @param filename The name of the file to be parsed.
577 */
578 @Deprecated
579 public JCTree.JCCompilationUnit parse(String filename) throws IOException {
580 JavacFileManager fm = (JavacFileManager)fileManager;
581 return parse(fm.getJavaFileObjectsFromStrings(List.of(filename)).iterator().next());
582 }
584 /** Parse contents of file.
585 * @param filename The name of the file to be parsed.
586 */
587 public JCTree.JCCompilationUnit parse(JavaFileObject filename) {
588 JavaFileObject prev = log.useSource(filename);
589 try {
590 JCTree.JCCompilationUnit t = parse(filename, readSource(filename));
591 if (t.endPositions != null)
592 log.setEndPosTable(filename, t.endPositions);
593 return t;
594 } finally {
595 log.useSource(prev);
596 }
597 }
599 /** Resolve an identifier.
600 * @param name The identifier to resolve
601 */
602 public Symbol resolveIdent(String name) {
603 if (name.equals(""))
604 return syms.errSymbol;
605 JavaFileObject prev = log.useSource(null);
606 try {
607 JCExpression tree = null;
608 for (String s : name.split("\\.", -1)) {
609 if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
610 return syms.errSymbol;
611 tree = (tree == null) ? make.Ident(names.fromString(s))
612 : make.Select(tree, names.fromString(s));
613 }
614 JCCompilationUnit toplevel =
615 make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
616 toplevel.packge = syms.unnamedPackage;
617 return attr.attribIdent(tree, toplevel);
618 } finally {
619 log.useSource(prev);
620 }
621 }
623 /** Emit plain Java source for a class.
624 * @param env The attribution environment of the outermost class
625 * containing this class.
626 * @param cdef The class definition to be printed.
627 */
628 JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
629 JavaFileObject outFile
630 = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
631 cdef.sym.flatname.toString(),
632 JavaFileObject.Kind.SOURCE,
633 null);
634 if (inputFiles.contains(outFile)) {
635 log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
636 return null;
637 } else {
638 BufferedWriter out = new BufferedWriter(outFile.openWriter());
639 try {
640 new Pretty(out, true).printUnit(env.toplevel, cdef);
641 if (verbose)
642 printVerbose("wrote.file", outFile);
643 } finally {
644 out.close();
645 }
646 return outFile;
647 }
648 }
650 /** Generate code and emit a class file for a given class
651 * @param env The attribution environment of the outermost class
652 * containing this class.
653 * @param cdef The class definition from which code is generated.
654 */
655 JavaFileObject genCode(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
656 try {
657 if (gen.genClass(env, cdef))
658 return writer.writeClass(cdef.sym);
659 } catch (ClassWriter.PoolOverflow ex) {
660 log.error(cdef.pos(), "limit.pool");
661 } catch (ClassWriter.StringOverflow ex) {
662 log.error(cdef.pos(), "limit.string.overflow",
663 ex.value.substring(0, 20));
664 } catch (CompletionFailure ex) {
665 chk.completionError(cdef.pos(), ex);
666 }
667 return null;
668 }
670 /** Complete compiling a source file that has been accessed
671 * by the class file reader.
672 * @param c The class the source file of which needs to be compiled.
673 * @param filename The name of the source file.
674 * @param f An input stream that reads the source file.
675 */
676 public void complete(ClassSymbol c) throws CompletionFailure {
677 // System.err.println("completing " + c);//DEBUG
678 if (completionFailureName == c.fullname) {
679 throw new CompletionFailure(c, "user-selected completion failure by class name");
680 }
681 JCCompilationUnit tree;
682 JavaFileObject filename = c.classfile;
683 JavaFileObject prev = log.useSource(filename);
685 try {
686 tree = parse(filename, filename.getCharContent(false));
687 } catch (IOException e) {
688 log.error("error.reading.file", filename, e);
689 tree = make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
690 } finally {
691 log.useSource(prev);
692 }
694 if (taskListener != null) {
695 TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
696 taskListener.started(e);
697 }
699 enter.complete(List.of(tree), c);
701 if (taskListener != null) {
702 TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
703 taskListener.finished(e);
704 }
706 if (enter.getEnv(c) == null) {
707 boolean isPkgInfo =
708 tree.sourcefile.isNameCompatible("package-info",
709 JavaFileObject.Kind.SOURCE);
710 if (isPkgInfo) {
711 if (enter.getEnv(tree.packge) == null) {
712 JCDiagnostic diag =
713 diagFactory.fragment("file.does.not.contain.package",
714 c.location());
715 throw reader.new BadClassFile(c, filename, diag);
716 }
717 } else {
718 JCDiagnostic diag =
719 diagFactory.fragment("file.doesnt.contain.class",
720 c.getQualifiedName());
721 throw reader.new BadClassFile(c, filename, diag);
722 }
723 }
725 implicitSourceFilesRead = true;
726 }
728 /** Track when the JavaCompiler has been used to compile something. */
729 private boolean hasBeenUsed = false;
730 private long start_msec = 0;
731 public long elapsed_msec = 0;
733 /** Track whether any errors occurred while parsing source text. */
734 private boolean parseErrors = false;
736 public void compile(List<JavaFileObject> sourceFileObject)
737 throws Throwable {
738 compile(sourceFileObject, List.<String>nil(), null);
739 }
741 /**
742 * Main method: compile a list of files, return all compiled classes
743 *
744 * @param sourceFileObjects file objects to be compiled
745 * @param classnames class names to process for annotations
746 * @param processors user provided annotation processors to bypass
747 * discovery, {@code null} means that no processors were provided
748 */
749 public void compile(List<JavaFileObject> sourceFileObjects,
750 List<String> classnames,
751 Iterable<? extends Processor> processors)
752 throws IOException // TODO: temp, from JavacProcessingEnvironment
753 {
754 if (processors != null && processors.iterator().hasNext())
755 explicitAnnotationProcessingRequested = true;
756 // as a JavaCompiler can only be used once, throw an exception if
757 // it has been used before.
758 if (hasBeenUsed)
759 throw new AssertionError("attempt to reuse JavaCompiler");
760 hasBeenUsed = true;
762 start_msec = now();
763 try {
764 initProcessAnnotations(processors);
766 // These method calls must be chained to avoid memory leaks
767 delegateCompiler = processAnnotations(enterTrees(stopIfError(parseFiles(sourceFileObjects))),
768 classnames);
770 delegateCompiler.compile2();
771 delegateCompiler.close();
772 elapsed_msec = delegateCompiler.elapsed_msec;
773 } catch (Abort ex) {
774 if (devVerbose)
775 ex.printStackTrace();
776 }
777 }
779 /**
780 * The phases following annotation processing: attribution,
781 * desugar, and finally code generation.
782 */
783 private void compile2() {
784 try {
785 switch (compilePolicy) {
786 case ATTR_ONLY:
787 attribute(todo);
788 break;
790 case CHECK_ONLY:
791 flow(attribute(todo));
792 break;
794 case SIMPLE:
795 generate(desugar(flow(attribute(todo))));
796 break;
798 case BY_FILE:
799 for (Queue<Env<AttrContext>> queue : groupByFile(flow(attribute(todo))).values())
800 generate(desugar(queue));
801 break;
803 case BY_TODO:
804 while (todo.nonEmpty())
805 generate(desugar(flow(attribute(todo.next()))));
806 break;
808 default:
809 assert false: "unknown compile policy";
810 }
811 } catch (Abort ex) {
812 if (devVerbose)
813 ex.printStackTrace();
814 }
816 if (verbose) {
817 elapsed_msec = elapsed(start_msec);
818 printVerbose("total", Long.toString(elapsed_msec));
819 }
821 reportDeferredDiagnostics();
823 if (!log.hasDiagnosticListener()) {
824 printCount("error", errorCount());
825 printCount("warn", warningCount());
826 }
827 }
829 private List<JCClassDecl> rootClasses;
831 /**
832 * Parses a list of files.
833 */
834 public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException {
835 if (errorCount() > 0)
836 return List.nil();
838 //parse all files
839 ListBuffer<JCCompilationUnit> trees = lb();
840 for (JavaFileObject fileObject : fileObjects)
841 trees.append(parse(fileObject));
842 return trees.toList();
843 }
845 /**
846 * Enter the symbols found in a list of parse trees.
847 * As a side-effect, this puts elements on the "todo" list.
848 * Also stores a list of all top level classes in rootClasses.
849 */
850 public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
851 //enter symbols for all files
852 if (taskListener != null) {
853 for (JCCompilationUnit unit: roots) {
854 TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
855 taskListener.started(e);
856 }
857 }
859 enter.main(roots);
861 if (taskListener != null) {
862 for (JCCompilationUnit unit: roots) {
863 TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
864 taskListener.finished(e);
865 }
866 }
868 //If generating source, remember the classes declared in
869 //the original compilation units listed on the command line.
870 if (sourceOutput || stubOutput) {
871 ListBuffer<JCClassDecl> cdefs = lb();
872 for (JCCompilationUnit unit : roots) {
873 for (List<JCTree> defs = unit.defs;
874 defs.nonEmpty();
875 defs = defs.tail) {
876 if (defs.head instanceof JCClassDecl)
877 cdefs.append((JCClassDecl)defs.head);
878 }
879 }
880 rootClasses = cdefs.toList();
881 }
882 return roots;
883 }
885 /**
886 * Set to true to enable skeleton annotation processing code.
887 * Currently, we assume this variable will be replaced more
888 * advanced logic to figure out if annotation processing is
889 * needed.
890 */
891 boolean processAnnotations = false;
893 /**
894 * Object to handle annotation processing.
895 */
896 JavacProcessingEnvironment procEnvImpl = null;
898 /**
899 * Check if we should process annotations.
900 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
901 * to catch doc comments, and set keepComments so the parser records them in
902 * the compilation unit.
903 *
904 * @param processors user provided annotation processors to bypass
905 * discovery, {@code null} means that no processors were provided
906 */
907 public void initProcessAnnotations(Iterable<? extends Processor> processors) {
908 // Process annotations if processing is not disabled and there
909 // is at least one Processor available.
910 Options options = Options.instance(context);
911 if (options.get("-proc:none") != null) {
912 processAnnotations = false;
913 } else if (procEnvImpl == null) {
914 procEnvImpl = new JavacProcessingEnvironment(context, processors);
915 processAnnotations = procEnvImpl.atLeastOneProcessor();
917 if (processAnnotations) {
918 if (context.get(Scanner.Factory.scannerFactoryKey) == null)
919 DocCommentScanner.Factory.preRegister(context);
920 options.put("save-parameter-names", "save-parameter-names");
921 reader.saveParameterNames = true;
922 keepComments = true;
923 if (taskListener != null)
924 taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
927 } else { // free resources
928 procEnvImpl.close();
929 }
930 }
931 }
933 // TODO: called by JavacTaskImpl
934 public JavaCompiler processAnnotations(List<JCCompilationUnit> roots) throws IOException {
935 return processAnnotations(roots, List.<String>nil());
936 }
938 /**
939 * Process any anotations found in the specifed compilation units.
940 * @param roots a list of compilation units
941 * @return an instance of the compiler in which to complete the compilation
942 */
943 public JavaCompiler processAnnotations(List<JCCompilationUnit> roots,
944 List<String> classnames)
945 throws IOException { // TODO: see TEMP note in JavacProcessingEnvironment
946 if (errorCount() != 0) {
947 // Errors were encountered. If todo is empty, then the
948 // encountered errors were parse errors. Otherwise, the
949 // errors were found during the enter phase which should
950 // be ignored when processing annotations.
952 if (todo.isEmpty())
953 return this;
954 }
956 // ASSERT: processAnnotations and procEnvImpl should have been set up by
957 // by initProcessAnnotations
959 // NOTE: The !classnames.isEmpty() checks should be refactored to Main.
961 if (!processAnnotations) {
962 // If there are no annotation processors present, and
963 // annotation processing is to occur with compilation,
964 // emit a warning.
965 Options options = Options.instance(context);
966 if (options.get("-proc:only") != null) {
967 log.warning("proc.proc-only.requested.no.procs");
968 todo.clear();
969 }
970 // If not processing annotations, classnames must be empty
971 if (!classnames.isEmpty()) {
972 log.error("proc.no.explicit.annotation.processing.requested",
973 classnames);
974 }
975 return this; // continue regular compilation
976 }
978 try {
979 List<ClassSymbol> classSymbols = List.nil();
980 List<PackageSymbol> pckSymbols = List.nil();
981 if (!classnames.isEmpty()) {
982 // Check for explicit request for annotation
983 // processing
984 if (!explicitAnnotationProcessingRequested()) {
985 log.error("proc.no.explicit.annotation.processing.requested",
986 classnames);
987 return this; // TODO: Will this halt compilation?
988 } else {
989 boolean errors = false;
990 for (String nameStr : classnames) {
991 Symbol sym = resolveIdent(nameStr);
992 if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) {
993 log.error("proc.cant.find.class", nameStr);
994 errors = true;
995 continue;
996 }
997 try {
998 if (sym.kind == Kinds.PCK)
999 sym.complete();
1000 if (sym.exists()) {
1001 Name name = names.fromString(nameStr);
1002 if (sym.kind == Kinds.PCK)
1003 pckSymbols = pckSymbols.prepend((PackageSymbol)sym);
1004 else
1005 classSymbols = classSymbols.prepend((ClassSymbol)sym);
1006 continue;
1007 }
1008 assert sym.kind == Kinds.PCK;
1009 log.warning("proc.package.does.not.exist", nameStr);
1010 pckSymbols = pckSymbols.prepend((PackageSymbol)sym);
1011 } catch (CompletionFailure e) {
1012 log.error("proc.cant.find.class", nameStr);
1013 errors = true;
1014 continue;
1015 }
1016 }
1017 if (errors)
1018 return this;
1019 }
1020 }
1021 JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols);
1022 if (c != this)
1023 annotationProcessingOccurred = c.annotationProcessingOccurred = true;
1024 return c;
1025 } catch (CompletionFailure ex) {
1026 log.error("cant.access", ex.sym, ex.getDetailValue());
1027 return this;
1029 }
1030 }
1032 boolean explicitAnnotationProcessingRequested() {
1033 Options options = Options.instance(context);
1034 return
1035 explicitAnnotationProcessingRequested ||
1036 options.get("-processor") != null ||
1037 options.get("-processorpath") != null ||
1038 options.get("-proc:only") != null ||
1039 options.get("-Xprint") != null;
1040 }
1042 /**
1043 * Attribute a list of parse trees, such as found on the "todo" list.
1044 * Note that attributing classes may cause additional files to be
1045 * parsed and entered via the SourceCompleter.
1046 * Attribution of the entries in the list does not stop if any errors occur.
1047 * @returns a list of environments for attributd classes.
1048 */
1049 public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) {
1050 ListBuffer<Env<AttrContext>> results = lb();
1051 while (!envs.isEmpty())
1052 results.append(attribute(envs.remove()));
1053 return results;
1054 }
1056 /**
1057 * Attribute a parse tree.
1058 * @returns the attributed parse tree
1059 */
1060 public Env<AttrContext> attribute(Env<AttrContext> env) {
1061 if (compileStates.isDone(env, CompileState.ATTR))
1062 return env;
1064 if (verboseCompilePolicy)
1065 log.printLines(log.noticeWriter, "[attribute " + env.enclClass.sym + "]");
1066 if (verbose)
1067 printVerbose("checking.attribution", env.enclClass.sym);
1069 if (taskListener != null) {
1070 TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
1071 taskListener.started(e);
1072 }
1074 JavaFileObject prev = log.useSource(
1075 env.enclClass.sym.sourcefile != null ?
1076 env.enclClass.sym.sourcefile :
1077 env.toplevel.sourcefile);
1078 try {
1079 attr.attribClass(env.tree.pos(), env.enclClass.sym);
1080 compileStates.put(env, CompileState.ATTR);
1081 }
1082 finally {
1083 log.useSource(prev);
1084 }
1086 return env;
1087 }
1089 /**
1090 * Perform dataflow checks on attributed parse trees.
1091 * These include checks for definite assignment and unreachable statements.
1092 * If any errors occur, an empty list will be returned.
1093 * @returns the list of attributed parse trees
1094 */
1095 public Queue<Env<AttrContext>> flow(Queue<Env<AttrContext>> envs) {
1096 ListBuffer<Env<AttrContext>> results = lb();
1097 for (Env<AttrContext> env: envs) {
1098 flow(env, results);
1099 }
1100 return stopIfError(results);
1101 }
1103 /**
1104 * Perform dataflow checks on an attributed parse tree.
1105 */
1106 public Queue<Env<AttrContext>> flow(Env<AttrContext> env) {
1107 ListBuffer<Env<AttrContext>> results = lb();
1108 flow(env, results);
1109 return stopIfError(results);
1110 }
1112 /**
1113 * Perform dataflow checks on an attributed parse tree.
1114 */
1115 protected void flow(Env<AttrContext> env, ListBuffer<Env<AttrContext>> results) {
1116 try {
1117 if (errorCount() > 0)
1118 return;
1120 if (relax || compileStates.isDone(env, CompileState.FLOW)) {
1121 results.append(env);
1122 return;
1123 }
1125 if (verboseCompilePolicy)
1126 log.printLines(log.noticeWriter, "[flow " + env.enclClass.sym + "]");
1127 JavaFileObject prev = log.useSource(
1128 env.enclClass.sym.sourcefile != null ?
1129 env.enclClass.sym.sourcefile :
1130 env.toplevel.sourcefile);
1131 try {
1132 make.at(Position.FIRSTPOS);
1133 TreeMaker localMake = make.forToplevel(env.toplevel);
1134 flow.analyzeTree(env.tree, localMake);
1135 compileStates.put(env, CompileState.FLOW);
1137 if (errorCount() > 0)
1138 return;
1140 results.append(env);
1141 }
1142 finally {
1143 log.useSource(prev);
1144 }
1145 }
1146 finally {
1147 if (taskListener != null) {
1148 TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
1149 taskListener.finished(e);
1150 }
1151 }
1152 }
1154 /**
1155 * Prepare attributed parse trees, in conjunction with their attribution contexts,
1156 * for source or code generation.
1157 * If any errors occur, an empty list will be returned.
1158 * @returns a list containing the classes to be generated
1159 */
1160 public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
1161 ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = lb();
1162 for (Env<AttrContext> env: envs)
1163 desugar(env, results);
1164 return stopIfError(results);
1165 }
1167 /**
1168 * Prepare attributed parse trees, in conjunction with their attribution contexts,
1169 * for source or code generation. If the file was not listed on the command line,
1170 * the current implicitSourcePolicy is taken into account.
1171 * The preparation stops as soon as an error is found.
1172 */
1173 protected void desugar(final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) {
1174 if (errorCount() > 0)
1175 return;
1177 if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
1178 && !inputFiles.contains(env.toplevel.sourcefile)) {
1179 return;
1180 }
1182 /**
1183 * As erasure (TransTypes) destroys information needed in flow analysis,
1184 * including information in supertypes, we need to ensure that supertypes
1185 * are processed through attribute and flow before subtypes are translated.
1186 */
1187 class ScanNested extends TreeScanner {
1188 Set<Env<AttrContext>> dependencies = new HashSet<Env<AttrContext>>();
1189 public void visitClassDef(JCClassDecl node) {
1190 Type st = types.supertype(node.sym.type);
1191 if (st.tag == TypeTags.CLASS) {
1192 ClassSymbol c = st.tsym.outermostClass();
1193 Env<AttrContext> stEnv = enter.getEnv(c);
1194 if (stEnv != null && env != stEnv)
1195 dependencies.add(stEnv);
1196 }
1197 super.visitClassDef(node);
1198 }
1199 }
1200 ScanNested scanner = new ScanNested();
1201 scanner.scan(env.tree);
1202 for (Env<AttrContext> dep: scanner.dependencies) {
1203 if (!compileStates.isDone(dep, CompileState.FLOW))
1204 flow(attribute(dep));
1205 }
1207 if (verboseCompilePolicy)
1208 log.printLines(log.noticeWriter, "[desugar " + env.enclClass.sym + "]");
1210 JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
1211 env.enclClass.sym.sourcefile :
1212 env.toplevel.sourcefile);
1213 try {
1214 //save tree prior to rewriting
1215 JCTree untranslated = env.tree;
1217 make.at(Position.FIRSTPOS);
1218 TreeMaker localMake = make.forToplevel(env.toplevel);
1220 if (env.tree instanceof JCCompilationUnit) {
1221 if (!(stubOutput || sourceOutput || printFlat)) {
1222 List<JCTree> pdef = lower.translateTopLevelClass(env, env.tree, localMake);
1223 if (pdef.head != null) {
1224 assert pdef.tail.isEmpty();
1225 results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, (JCClassDecl)pdef.head));
1226 }
1227 }
1228 return;
1229 }
1231 if (stubOutput) {
1232 //emit stub Java source file, only for compilation
1233 //units enumerated explicitly on the command line
1234 JCClassDecl cdef = (JCClassDecl)env.tree;
1235 if (untranslated instanceof JCClassDecl &&
1236 rootClasses.contains((JCClassDecl)untranslated) &&
1237 ((cdef.mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1238 cdef.sym.packge().getQualifiedName() == names.java_lang)) {
1239 results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, removeMethodBodies(cdef)));
1240 }
1241 return;
1242 }
1244 env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
1246 if (errorCount() != 0)
1247 return;
1249 if (sourceOutput) {
1250 //emit standard Java source file, only for compilation
1251 //units enumerated explicitly on the command line
1252 JCClassDecl cdef = (JCClassDecl)env.tree;
1253 if (untranslated instanceof JCClassDecl &&
1254 rootClasses.contains((JCClassDecl)untranslated)) {
1255 results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
1256 }
1257 return;
1258 }
1260 //translate out inner classes
1261 List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
1263 if (errorCount() != 0)
1264 return;
1266 //generate code for each class
1267 for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
1268 JCClassDecl cdef = (JCClassDecl)l.head;
1269 results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
1270 }
1271 }
1272 finally {
1273 log.useSource(prev);
1274 }
1276 }
1278 /** Generates the source or class file for a list of classes.
1279 * The decision to generate a source file or a class file is
1280 * based upon the compiler's options.
1281 * Generation stops if an error occurs while writing files.
1282 */
1283 public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue) {
1284 generate(queue, null);
1285 }
1287 public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, ListBuffer<JavaFileObject> results) {
1288 boolean usePrintSource = (stubOutput || sourceOutput || printFlat);
1290 for (Pair<Env<AttrContext>, JCClassDecl> x: queue) {
1291 Env<AttrContext> env = x.fst;
1292 JCClassDecl cdef = x.snd;
1294 if (verboseCompilePolicy) {
1295 log.printLines(log.noticeWriter, "[generate "
1296 + (usePrintSource ? " source" : "code")
1297 + " " + env.enclClass.sym + "]");
1298 }
1300 if (taskListener != null) {
1301 TaskEvent e = new TaskEvent(TaskEvent.Kind.GENERATE, env.toplevel, cdef.sym);
1302 taskListener.started(e);
1303 }
1305 JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
1306 env.enclClass.sym.sourcefile :
1307 env.toplevel.sourcefile);
1308 try {
1309 JavaFileObject file;
1310 if (usePrintSource)
1311 file = printSource(env, cdef);
1312 else
1313 file = genCode(env, cdef);
1314 if (results != null && file != null)
1315 results.append(file);
1316 } catch (IOException ex) {
1317 log.error(cdef.pos(), "class.cant.write",
1318 cdef.sym, ex.getMessage());
1319 return;
1320 } finally {
1321 log.useSource(prev);
1322 }
1324 if (taskListener != null) {
1325 TaskEvent e = new TaskEvent(TaskEvent.Kind.GENERATE, env.toplevel, cdef.sym);
1326 taskListener.finished(e);
1327 }
1328 }
1329 }
1331 // where
1332 Map<JCCompilationUnit, Queue<Env<AttrContext>>> groupByFile(Queue<Env<AttrContext>> envs) {
1333 // use a LinkedHashMap to preserve the order of the original list as much as possible
1334 Map<JCCompilationUnit, Queue<Env<AttrContext>>> map = new LinkedHashMap<JCCompilationUnit, Queue<Env<AttrContext>>>();
1335 for (Env<AttrContext> env: envs) {
1336 Queue<Env<AttrContext>> sublist = map.get(env.toplevel);
1337 if (sublist == null) {
1338 sublist = new ListBuffer<Env<AttrContext>>();
1339 map.put(env.toplevel, sublist);
1340 }
1341 sublist.add(env);
1342 }
1343 return map;
1344 }
1346 JCClassDecl removeMethodBodies(JCClassDecl cdef) {
1347 final boolean isInterface = (cdef.mods.flags & Flags.INTERFACE) != 0;
1348 class MethodBodyRemover extends TreeTranslator {
1349 public void visitMethodDef(JCMethodDecl tree) {
1350 tree.mods.flags &= ~Flags.SYNCHRONIZED;
1351 for (JCVariableDecl vd : tree.params)
1352 vd.mods.flags &= ~Flags.FINAL;
1353 tree.body = null;
1354 super.visitMethodDef(tree);
1355 }
1356 public void visitVarDef(JCVariableDecl tree) {
1357 if (tree.init != null && tree.init.type.constValue() == null)
1358 tree.init = null;
1359 super.visitVarDef(tree);
1360 }
1361 public void visitClassDef(JCClassDecl tree) {
1362 ListBuffer<JCTree> newdefs = lb();
1363 for (List<JCTree> it = tree.defs; it.tail != null; it = it.tail) {
1364 JCTree t = it.head;
1365 switch (t.getTag()) {
1366 case JCTree.CLASSDEF:
1367 if (isInterface ||
1368 (((JCClassDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1369 (((JCClassDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCClassDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1370 newdefs.append(t);
1371 break;
1372 case JCTree.METHODDEF:
1373 if (isInterface ||
1374 (((JCMethodDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1375 ((JCMethodDecl) t).sym.name == names.init ||
1376 (((JCMethodDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCMethodDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1377 newdefs.append(t);
1378 break;
1379 case JCTree.VARDEF:
1380 if (isInterface || (((JCVariableDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1381 (((JCVariableDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCVariableDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1382 newdefs.append(t);
1383 break;
1384 default:
1385 break;
1386 }
1387 }
1388 tree.defs = newdefs.toList();
1389 super.visitClassDef(tree);
1390 }
1391 }
1392 MethodBodyRemover r = new MethodBodyRemover();
1393 return r.translate(cdef);
1394 }
1396 public void reportDeferredDiagnostics() {
1397 if (annotationProcessingOccurred
1398 && implicitSourceFilesRead
1399 && implicitSourcePolicy == ImplicitSourcePolicy.UNSET) {
1400 if (explicitAnnotationProcessingRequested())
1401 log.warning("proc.use.implicit");
1402 else
1403 log.warning("proc.use.proc.or.implicit");
1404 }
1405 chk.reportDeferredDiagnostics();
1406 }
1408 /** Close the compiler, flushing the logs
1409 */
1410 public void close() {
1411 close(true);
1412 }
1414 private void close(boolean disposeNames) {
1415 rootClasses = null;
1416 reader = null;
1417 make = null;
1418 writer = null;
1419 enter = null;
1420 if (todo != null)
1421 todo.clear();
1422 todo = null;
1423 parserFactory = null;
1424 syms = null;
1425 source = null;
1426 attr = null;
1427 chk = null;
1428 gen = null;
1429 flow = null;
1430 transTypes = null;
1431 lower = null;
1432 annotate = null;
1433 types = null;
1435 log.flush();
1436 try {
1437 fileManager.flush();
1438 } catch (IOException e) {
1439 throw new Abort(e);
1440 } finally {
1441 if (names != null && disposeNames)
1442 names.dispose();
1443 names = null;
1444 }
1445 }
1447 /** Output for "-verbose" option.
1448 * @param key The key to look up the correct internationalized string.
1449 * @param arg An argument for substitution into the output string.
1450 */
1451 protected void printVerbose(String key, Object arg) {
1452 Log.printLines(log.noticeWriter, log.getLocalizedString("verbose." + key, arg));
1453 }
1455 /** Print numbers of errors and warnings.
1456 */
1457 protected void printCount(String kind, int count) {
1458 if (count != 0) {
1459 String text;
1460 if (count == 1)
1461 text = log.getLocalizedString("count." + kind, String.valueOf(count));
1462 else
1463 text = log.getLocalizedString("count." + kind + ".plural", String.valueOf(count));
1464 Log.printLines(log.errWriter, text);
1465 log.errWriter.flush();
1466 }
1467 }
1469 private static long now() {
1470 return System.currentTimeMillis();
1471 }
1473 private static long elapsed(long then) {
1474 return now() - then;
1475 }
1477 public void initRound(JavaCompiler prev) {
1478 keepComments = prev.keepComments;
1479 start_msec = prev.start_msec;
1480 hasBeenUsed = true;
1481 }
1483 public static void enableLogging() {
1484 Logger logger = Logger.getLogger(com.sun.tools.javac.Main.class.getPackage().getName());
1485 logger.setLevel(Level.ALL);
1486 for (Handler h : logger.getParent().getHandlers()) {
1487 h.setLevel(Level.ALL);
1488 }
1490 }
1491 }