src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
Print this page
*** 872,895 ****
compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
JavaFileManager fileManager = currentContext.get(JavaFileManager.class);
- List<JavaFileObject> fileObjects = List.nil();
- for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
- fileObjects = fileObjects.prepend(jfo);
- }
-
-
compiler = JavaCompiler.instance(currentContext);
! List<JCCompilationUnit> parsedFiles = compiler.parseFiles(fileObjects);
! roots = cleanTrees(roots).reverse();
!
!
! for (JCCompilationUnit unit : parsedFiles)
! roots = roots.prepend(unit);
! roots = roots.reverse();
// Check for errors after parsing
if (compiler.parseErrors()) {
errorStatus = true;
break runAround;
--- 872,884 ----
compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
JavaFileManager fileManager = currentContext.get(JavaFileManager.class);
compiler = JavaCompiler.instance(currentContext);
! List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler);
! roots = cleanTrees(roots).appendList(parsedFiles);
// Check for errors after parsing
if (compiler.parseErrors()) {
errorStatus = true;
break runAround;
*** 919,933 ****
}
} else
break runAround; // No new files
}
}
! runLastRound(xout, roundNumber, errorStatus, taskListener);
compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
compiler = JavaCompiler.instance(currentContext);
filer.newRound(currentContext, true);
filer.warnIfUnclosedFiles();
warnIfUnmatchedOptions();
/*
--- 908,927 ----
}
} else
break runAround; // No new files
}
}
! roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener);
! // Set error status for any files compiled and generated in
! // the last round
! if (compiler.parseErrors())
! errorStatus = true;
compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
compiler = JavaCompiler.instance(currentContext);
+
filer.newRound(currentContext, true);
filer.warnIfUnclosedFiles();
warnIfUnmatchedOptions();
/*
*** 977,990 ****
}
return compiler;
}
// Call the last round of annotation processing
! private void runLastRound(PrintWriter xout,
int roundNumber,
boolean errorStatus,
TaskListener taskListener) throws IOException {
roundNumber++;
List<ClassSymbol> noTopLevelClasses = List.nil();
Set<TypeElement> noAnnotations = Collections.emptySet();
printRoundInfo(xout, roundNumber, noTopLevelClasses, noAnnotations, true);
--- 971,996 ----
}
return compiler;
}
+ private List<JCCompilationUnit> sourcesToParsedFiles(JavaCompiler compiler)
+ throws IOException {
+ List<JavaFileObject> fileObjects = List.nil();
+ for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
+ fileObjects = fileObjects.prepend(jfo);
+ }
+
+ return compiler.parseFiles(fileObjects);
+ }
+
// Call the last round of annotation processing
! private List<JCCompilationUnit> runLastRound(PrintWriter xout,
int roundNumber,
boolean errorStatus,
+ JavaCompiler compiler,
+ List<JCCompilationUnit> roots,
TaskListener taskListener) throws IOException {
roundNumber++;
List<ClassSymbol> noTopLevelClasses = List.nil();
Set<TypeElement> noAnnotations = Collections.emptySet();
printRoundInfo(xout, roundNumber, noTopLevelClasses, noAnnotations, true);
*** 1001,1010 ****
--- 1007,1025 ----
discoveredProcs.iterator().runContributingProcs(renv);
} finally {
if (taskListener != null)
taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
}
+
+ // Add any sources generated during the last round to the set
+ // of files to be compiled.
+ if (moreToDo()) {
+ List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler);
+ roots = cleanTrees(roots).appendList(parsedFiles);
+ }
+
+ return roots;
}
private void updateProcessingState(Context currentContext, boolean lastRound) {
filer.newRound(currentContext, lastRound);
messager.newRound(currentContext);