boolean doFinish = false;
// For each, ask the host for every possible deferred binding answer.
for (Map.Entry<String, MessageSendSite> entry : requestedTypes.entrySet()) {
String reqType = entry.getKey();
MessageSendSite site = entry.getValue();
try {
String[] resultTypes = rebindPermOracle.getAllPossibleRebindAnswers(
logger, reqType);
rebindAnswers.put(reqType, resultTypes);
Collections.addAll(dependentTypeNames, resultTypes);
doFinish = true;
} catch (UnableToCompleteException e) {
FindDeferredBindingSitesVisitor.reportRebindProblem(site,
"Failed to resolve '" + reqType + "' via deferred binding");
rebindAnswers.put(reqType, new String[0]);
}
}
/*
* Create a a fragment loader for each GWT.runAsync call. They must be
* created now, rather than in ReplaceRunAsyncs, because all generated
* classes need to be created before GenerateJavaAST. Note that the loaders
* created are not yet associated with the specific sites. The present task
* is only to make sure that enough loaders exist. The real association
* between loaders and runAsync sites will be made in ReplaceRunAsyncs.
*/
for (MessageSendSite site : v.getRunAsyncSites()) {
String resultType;
try {
resultType = fragmentLoaderCreator.create(logger);
dependentTypeNames.add(resultType);
doFinish = true;
} catch (UnableToCompleteException e) {
FindDeferredBindingSitesVisitor.reportRebindProblem(site,
"Failed to create a runAsync fragment loader");
}
}
if (doFinish) {
try {
rebindPermOracle.getGeneratorContext().finish(logger);
} catch (UnableToCompleteException e) {
throw new RuntimeException("Unable to commit generated files", e);
}
}
// Sanity check all rebind answers.
for (Map.Entry<String, MessageSendSite> entry : requestedTypes.entrySet()) {
String reqType = entry.getKey();
MessageSendSite site = entry.getValue();
String[] resultTypes = rebindAnswers.get(reqType);
// Check that each result is instantiable.
for (String typeName : resultTypes) {
checkRebindResultInstantiable(site, typeName);
}