}
private CompilationState constructJavaAst(String[] additionalRootTypes)
throws UnableToCompleteException {
Set<String> allRootTypes = new TreeSet<String>();
CompilationState compilationState = rpo.getCompilationState();
Memory.maybeDumpMemory("CompStateBuilt");
populateRootTypes(allRootTypes, additionalRootTypes, compilationState.getTypeOracle());
String entryMethodHolderTypeName =
buildEntryMethodHolder(rpo.getGeneratorContext(), allRootTypes);
beforeUnifyAst(allRootTypes);
unifyJavaAst(allRootTypes, entryMethodHolderTypeName);
if (options.isSoycEnabled() || options.isJsonSoycEnabled()) {
SourceInfoCorrelator.exec(jprogram);
}
// Gathers simple metrics that can highlight overly-large modules in an incremental compile.
TinyCompileSummary tinyCompileSummary = compilerContext.getTinyCompileSummary();
tinyCompileSummary.setTypesForGeneratorsCount(
rpo.getGeneratorContext().getTypeOracle().getTypes().length);
tinyCompileSummary.setTypesForAstCount(jprogram.getDeclaredTypes().size());
tinyCompileSummary.setStaticSourceFilesCount(compilationState.getStaticSourceCount());
tinyCompileSummary.setGeneratedSourceFilesCount(compilationState.getGeneratedSourceCount());
tinyCompileSummary.setCachedStaticSourceFilesCount(
compilationState.getCachedStaticSourceCount());
tinyCompileSummary.setCachedGeneratedSourceFilesCount(
compilationState.getCachedGeneratedSourceCount());
// Free up memory.
rpo.clear();
jprogram.typeOracle.computeBeforeAST();
return compilationState;