926 printCount("error", errorCount()); |
926 printCount("error", errorCount()); |
927 printCount("warn", warningCount()); |
927 printCount("warn", warningCount()); |
928 } |
928 } |
929 } |
929 } |
930 |
930 |
|
931 /** |
|
932 * Set needRootClasses to true, in JavaCompiler subclass constructor |
|
933 * that want to collect public apis of classes supplied on the command line. |
|
934 */ |
|
935 protected boolean needRootClasses = false; |
|
936 |
|
937 /** |
|
938 * The list of classes explicitly supplied on the command line for compilation. |
|
939 * Not always populated. |
|
940 */ |
931 private List<JCClassDecl> rootClasses; |
941 private List<JCClassDecl> rootClasses; |
932 |
942 |
933 /** |
943 /** |
934 * Parses a list of files. |
944 * Parses a list of files. |
935 */ |
945 */ |
982 TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit); |
992 TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit); |
983 taskListener.finished(e); |
993 taskListener.finished(e); |
984 } |
994 } |
985 } |
995 } |
986 |
996 |
987 //If generating source, remember the classes declared in |
997 // If generating source, or if tracking public apis, |
988 //the original compilation units listed on the command line. |
998 // then remember the classes declared in |
989 if (sourceOutput || stubOutput) { |
999 // the original compilation units listed on the command line. |
|
1000 if (needRootClasses || sourceOutput || stubOutput) { |
990 ListBuffer<JCClassDecl> cdefs = lb(); |
1001 ListBuffer<JCClassDecl> cdefs = lb(); |
991 for (JCCompilationUnit unit : roots) { |
1002 for (JCCompilationUnit unit : roots) { |
992 for (List<JCTree> defs = unit.defs; |
1003 for (List<JCTree> defs = unit.defs; |
993 defs.nonEmpty(); |
1004 defs.nonEmpty(); |
994 defs = defs.tail) { |
1005 defs = defs.tail) { |
1245 //if in fail-over mode, ensure that AST expression nodes |
1256 //if in fail-over mode, ensure that AST expression nodes |
1246 //are correctly initialized (e.g. they have a type/symbol) |
1257 //are correctly initialized (e.g. they have a type/symbol) |
1247 attr.postAttr(env.tree); |
1258 attr.postAttr(env.tree); |
1248 } |
1259 } |
1249 compileStates.put(env, CompileState.ATTR); |
1260 compileStates.put(env, CompileState.ATTR); |
|
1261 if (rootClasses != null && rootClasses.contains(env.enclClass)) { |
|
1262 // This was a class that was explicitly supplied for compilation. |
|
1263 // If we want to capture the public api of this class, |
|
1264 // then now is a good time to do it. |
|
1265 reportPublicApi(env.enclClass.sym); |
|
1266 } |
1250 } |
1267 } |
1251 finally { |
1268 finally { |
1252 log.useSource(prev); |
1269 log.useSource(prev); |
1253 } |
1270 } |
1254 |
1271 |
1255 return env; |
1272 return env; |
|
1273 } |
|
1274 |
|
1275 /** Report the public api of a class that was supplied explicitly for compilation, |
|
1276 * for example on the command line to javac. |
|
1277 * @param sym The symbol of the class. |
|
1278 */ |
|
1279 public void reportPublicApi(ClassSymbol sym) { |
|
1280 // Override to collect the reported public api. |
1256 } |
1281 } |
1257 |
1282 |
1258 /** |
1283 /** |
1259 * Perform dataflow checks on attributed parse trees. |
1284 * Perform dataflow checks on attributed parse trees. |
1260 * These include checks for definite assignment and unreachable statements. |
1285 * These include checks for definite assignment and unreachable statements. |