private static void findEntryPoints(TreeLogger logger,
RebindPermutationOracle rpo, String[] mainClassNames, JProgram program)
throws UnableToCompleteException {
SourceInfo sourceInfo = program.createSourceInfoSynthetic(
JavaToJavaScriptCompiler.class, "Bootstrap method");
JMethod bootStrapMethod = program.createMethod(sourceInfo,
"init".toCharArray(), program.getIndexedType("EntryMethodHolder"),
program.getTypeVoid(), false, true, true, false, false);
bootStrapMethod.freezeParamTypes();
JMethodBody body = (JMethodBody) bootStrapMethod.getBody();
JBlock block = body.getBlock();
// Also remember $entry, which we'll handle specially in GenerateJsAst
JMethod registerEntry = program.getIndexedMethod("Impl.registerEntry");
program.addEntryMethod(registerEntry);
for (String mainClassName : mainClassNames) {
block.addStmt(makeStatsCalls(program, mainClassName));
JDeclaredType mainType = program.getFromTypeMap(mainClassName);
if (mainType == null) {
logger.log(TreeLogger.ERROR,
"Could not find module entry point class '" + mainClassName + "'",
null);
throw new UnableToCompleteException();
}
JMethod mainMethod = findMainMethod(mainType);
if (mainMethod != null && mainMethod.isStatic()) {
JMethodCall onModuleLoadCall = new JMethodCall(null, null, mainMethod);
block.addStmt(onModuleLoadCall.makeStatement());
continue;
}