diff -r 3207422a0f9b -r 9bfad4b4b6a2 langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Sep 25 13:06:58 2012 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Sep 25 13:11:05 2012 -0700 @@ -97,11 +97,9 @@ private final boolean printRounds; private final boolean verbose; private final boolean lint; - private final boolean procOnly; private final boolean fatalErrors; private final boolean werror; private final boolean showResolveErrors; - private boolean foundTypeProcessors; private final JavacFiler filer; private final JavacMessager messager; @@ -167,12 +165,14 @@ printRounds = options.isSet(XPRINTROUNDS); verbose = options.isSet(VERBOSE); lint = Lint.instance(context).isEnabled(PROCESSING); - procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT); + if (options.isSet(PROC, "only") || options.isSet(XPRINT)) { + JavaCompiler compiler = JavaCompiler.instance(context); + compiler.shouldStopPolicyIfNoError = CompileState.PROCESS; + } fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(WERROR); platformAnnotations = initPlatformAnnotations(); - foundTypeProcessors = false; // Initialize services before any processors are initialized // in case processors use them. @@ -462,7 +462,7 @@ * State about how a processor has been used by the tool. If a * processor has been used on a prior round, its process method is * called on all subsequent rounds, perhaps with an empty set of - * annotations to process. The {@code annotatedSupported} method + * annotations to process. The {@code annotationSupported} method * caches the supported annotation information from the first (and * only) getSupportedAnnotationTypes call to the processor. */ @@ -882,7 +882,9 @@ /** Create the compiler to be used for the final compilation. */ JavaCompiler finalCompiler(boolean errorStatus) { try { - JavaCompiler c = JavaCompiler.instance(nextContext()); + Context nextCtx = nextContext(); + JavacProcessingEnvironment.this.context = nextCtx; + JavaCompiler c = JavaCompiler.instance(nextCtx); c.log.nwarnings += compiler.log.nwarnings; if (errorStatus) { c.log.nerrors += compiler.log.nerrors; @@ -1021,7 +1023,7 @@ } /** Get the context for the next round of processing. - * Important values are propogated from round to round; + * Important values are propagated from round to round; * other values are implicitly reset. */ private Context nextContext() { @@ -1190,14 +1192,7 @@ return compiler; } - if (procOnly && !foundTypeProcessors) { - compiler.todo.clear(); - } else { - if (procOnly && foundTypeProcessors) - compiler.shouldStopPolicy = CompileState.FLOW; - - compiler.enterTrees(roots); - } + compiler.enterTreesIfNeeded(roots); return compiler; }