1.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon Feb 15 16:09:50 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon Feb 15 18:20:57 2010 -0800 1.3 @@ -874,20 +874,9 @@ 1.4 1.5 JavaFileManager fileManager = currentContext.get(JavaFileManager.class); 1.6 1.7 - List<JavaFileObject> fileObjects = List.nil(); 1.8 - for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) { 1.9 - fileObjects = fileObjects.prepend(jfo); 1.10 - } 1.11 - 1.12 - 1.13 compiler = JavaCompiler.instance(currentContext); 1.14 - List<JCCompilationUnit> parsedFiles = compiler.parseFiles(fileObjects); 1.15 - roots = cleanTrees(roots).reverse(); 1.16 - 1.17 - 1.18 - for (JCCompilationUnit unit : parsedFiles) 1.19 - roots = roots.prepend(unit); 1.20 - roots = roots.reverse(); 1.21 + List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler); 1.22 + roots = cleanTrees(roots).appendList(parsedFiles); 1.23 1.24 // Check for errors after parsing 1.25 if (compiler.parseErrors()) { 1.26 @@ -921,11 +910,16 @@ 1.27 break runAround; // No new files 1.28 } 1.29 } 1.30 - runLastRound(xout, roundNumber, errorStatus, taskListener); 1.31 + roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener); 1.32 + // Set error status for any files compiled and generated in 1.33 + // the last round 1.34 + if (compiler.parseErrors()) 1.35 + errorStatus = true; 1.36 1.37 compiler.close(false); 1.38 currentContext = contextForNextRound(currentContext, true); 1.39 compiler = JavaCompiler.instance(currentContext); 1.40 + 1.41 filer.newRound(currentContext, true); 1.42 filer.warnIfUnclosedFiles(); 1.43 warnIfUnmatchedOptions(); 1.44 @@ -979,10 +973,22 @@ 1.45 return compiler; 1.46 } 1.47 1.48 + private List<JCCompilationUnit> sourcesToParsedFiles(JavaCompiler compiler) 1.49 + throws IOException { 1.50 + List<JavaFileObject> fileObjects = List.nil(); 1.51 + for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) { 1.52 + fileObjects = fileObjects.prepend(jfo); 1.53 + } 1.54 + 1.55 + return compiler.parseFiles(fileObjects); 1.56 + } 1.57 + 1.58 // Call the last round of annotation processing 1.59 - private void runLastRound(PrintWriter xout, 1.60 - int roundNumber, 1.61 - boolean errorStatus, 1.62 + private List<JCCompilationUnit> runLastRound(PrintWriter xout, 1.63 + int roundNumber, 1.64 + boolean errorStatus, 1.65 + JavaCompiler compiler, 1.66 + List<JCCompilationUnit> roots, 1.67 TaskListener taskListener) throws IOException { 1.68 roundNumber++; 1.69 List<ClassSymbol> noTopLevelClasses = List.nil(); 1.70 @@ -1003,6 +1009,15 @@ 1.71 if (taskListener != null) 1.72 taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); 1.73 } 1.74 + 1.75 + // Add any sources generated during the last round to the set 1.76 + // of files to be compiled. 1.77 + if (moreToDo()) { 1.78 + List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler); 1.79 + roots = cleanTrees(roots).appendList(parsedFiles); 1.80 + } 1.81 + 1.82 + return roots; 1.83 } 1.84 1.85 private void updateProcessingState(Context currentContext, boolean lastRound) {