langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
changeset 2514 f8929e3790b4
parent 2212 1d3dc0e0ba0c
child 2984 e15ff3a34054
equal deleted inserted replaced
2513:1cbbf23b22f9 2514:f8929e3790b4
   384 
   384 
   385         completionFailureName =
   385         completionFailureName =
   386             (options.get("failcomplete") != null)
   386             (options.get("failcomplete") != null)
   387             ? names.fromString(options.get("failcomplete"))
   387             ? names.fromString(options.get("failcomplete"))
   388             : null;
   388             : null;
       
   389 
       
   390         shouldStopPolicy =
       
   391             (options.get("shouldStopPolicy") != null)
       
   392             ? CompileState.valueOf(options.get("shouldStopPolicy"))
       
   393             : null;
   389     }
   394     }
   390 
   395 
   391     /* Switches:
   396     /* Switches:
   392      */
   397      */
   393 
   398 
   457     /**
   462     /**
   458      * Report activity related to compilePolicy
   463      * Report activity related to compilePolicy
   459      */
   464      */
   460     public boolean verboseCompilePolicy;
   465     public boolean verboseCompilePolicy;
   461 
   466 
       
   467     /**
       
   468      * Policy of how far to continue processing. null means until first
       
   469      * error.
       
   470      */
       
   471     public CompileState shouldStopPolicy;
       
   472 
   462     /** A queue of all as yet unattributed classes.
   473     /** A queue of all as yet unattributed classes.
   463      */
   474      */
   464     public Todo todo;
   475     public Todo todo;
   465 
   476 
       
   477     /** Ordered list of compiler phases for each compilation unit. */
   466     protected enum CompileState {
   478     protected enum CompileState {
   467         TODO(0),
   479         PARSE(1),
   468         ATTR(1),
   480         ENTER(2),
   469         FLOW(2);
   481         PROCESS(3),
       
   482         ATTR(4),
       
   483         FLOW(5),
       
   484         TRANSTYPES(6),
       
   485         LOWER(7),
       
   486         GENERATE(8);
   470         CompileState(int value) {
   487         CompileState(int value) {
   471             this.value = value;
   488             this.value = value;
   472         }
   489         }
   473         boolean isDone(CompileState other) {
   490         boolean isDone(CompileState other) {
   474             return value >= other.value;
   491             return value >= other.value;
   475         }
   492         }
   476         private int value;
   493         private int value;
   477     };
   494     };
       
   495     /** Partial map to record which compiler phases have been executed
       
   496      * for each compilation unit. Used for ATTR and FLOW phases.
       
   497      */
   478     protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> {
   498     protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> {
   479         private static final long serialVersionUID = 1812267524140424433L;
   499         private static final long serialVersionUID = 1812267524140424433L;
   480         boolean isDone(Env<AttrContext> env, CompileState cs) {
   500         boolean isDone(Env<AttrContext> env, CompileState cs) {
   481             CompileState ecs = get(env);
   501             CompileState ecs = get(env);
   482             return ecs != null && ecs.isDone(cs);
   502             return ecs != null && ecs.isDone(cs);
   487     /** The set of currently compiled inputfiles, needed to ensure
   507     /** The set of currently compiled inputfiles, needed to ensure
   488      *  we don't accidentally overwrite an input file when -s is set.
   508      *  we don't accidentally overwrite an input file when -s is set.
   489      *  initialized by `compile'.
   509      *  initialized by `compile'.
   490      */
   510      */
   491     protected Set<JavaFileObject> inputFiles = new HashSet<JavaFileObject>();
   511     protected Set<JavaFileObject> inputFiles = new HashSet<JavaFileObject>();
       
   512 
       
   513     protected boolean shouldStop(CompileState cs) {
       
   514         if (shouldStopPolicy == null)
       
   515             return (errorCount() > 0);
       
   516         else
       
   517             return cs.ordinal() > shouldStopPolicy.ordinal();
       
   518     }
   492 
   519 
   493     /** The number of errors reported so far.
   520     /** The number of errors reported so far.
   494      */
   521      */
   495     public int errorCount() {
   522     public int errorCount() {
   496         if (delegateCompiler != null && delegateCompiler != this)
   523         if (delegateCompiler != null && delegateCompiler != this)
   501             }
   528             }
   502         }
   529         }
   503             return log.nerrors;
   530             return log.nerrors;
   504     }
   531     }
   505 
   532 
   506     protected final <T> Queue<T> stopIfError(Queue<T> queue) {
   533     protected final <T> Queue<T> stopIfError(CompileState cs, Queue<T> queue) {
   507         if (errorCount() == 0)
   534         return shouldStop(cs) ? ListBuffer.<T>lb() : queue;
   508             return queue;
   535     }
   509         else
   536 
   510             return ListBuffer.lb();
   537     protected final <T> List<T> stopIfError(CompileState cs, List<T> list) {
   511     }
   538         return shouldStop(cs) ? List.<T>nil() : list;
   512 
       
   513     protected final <T> List<T> stopIfError(List<T> list) {
       
   514         if (errorCount() == 0)
       
   515             return list;
       
   516         else
       
   517             return List.nil();
       
   518     }
   539     }
   519 
   540 
   520     /** The number of warnings reported so far.
   541     /** The number of warnings reported so far.
   521      */
   542      */
   522     public int warningCount() {
   543     public int warningCount() {
   667      *                containing this class.
   688      *                containing this class.
   668      *  @param cdef   The class definition from which code is generated.
   689      *  @param cdef   The class definition from which code is generated.
   669      */
   690      */
   670     JavaFileObject genCode(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
   691     JavaFileObject genCode(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
   671         try {
   692         try {
   672             if (gen.genClass(env, cdef))
   693             if (gen.genClass(env, cdef) && (errorCount() == 0))
   673                 return writer.writeClass(cdef.sym);
   694                 return writer.writeClass(cdef.sym);
   674         } catch (ClassWriter.PoolOverflow ex) {
   695         } catch (ClassWriter.PoolOverflow ex) {
   675             log.error(cdef.pos(), "limit.pool");
   696             log.error(cdef.pos(), "limit.pool");
   676         } catch (ClassWriter.StringOverflow ex) {
   697         } catch (ClassWriter.StringOverflow ex) {
   677             log.error(cdef.pos(), "limit.string.overflow",
   698             log.error(cdef.pos(), "limit.string.overflow",
   777         start_msec = now();
   798         start_msec = now();
   778         try {
   799         try {
   779             initProcessAnnotations(processors);
   800             initProcessAnnotations(processors);
   780 
   801 
   781             // These method calls must be chained to avoid memory leaks
   802             // These method calls must be chained to avoid memory leaks
   782             delegateCompiler = processAnnotations(enterTrees(stopIfError(parseFiles(sourceFileObjects))),
   803             delegateCompiler =
   783                                                   classnames);
   804                 processAnnotations(
       
   805                     enterTrees(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))),
       
   806                     classnames);
   784 
   807 
   785             delegateCompiler.compile2();
   808             delegateCompiler.compile2();
   786             delegateCompiler.close();
   809             delegateCompiler.close();
   787             elapsed_msec = delegateCompiler.elapsed_msec;
   810             elapsed_msec = delegateCompiler.elapsed_msec;
   788         } catch (Abort ex) {
   811         } catch (Abort ex) {
   810                 generate(desugar(flow(attribute(todo))));
   833                 generate(desugar(flow(attribute(todo))));
   811                 break;
   834                 break;
   812 
   835 
   813             case BY_FILE: {
   836             case BY_FILE: {
   814                     Queue<Queue<Env<AttrContext>>> q = todo.groupByFile();
   837                     Queue<Queue<Env<AttrContext>>> q = todo.groupByFile();
   815                     while (!q.isEmpty() && errorCount() == 0) {
   838                     while (!q.isEmpty() && !shouldStop(CompileState.ATTR)) {
   816                         generate(desugar(flow(attribute(q.remove()))));
   839                         generate(desugar(flow(attribute(q.remove()))));
   817                     }
   840                     }
   818                 }
   841                 }
   819                 break;
   842                 break;
   820 
   843 
   848 
   871 
   849     /**
   872     /**
   850      * Parses a list of files.
   873      * Parses a list of files.
   851      */
   874      */
   852    public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException {
   875    public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException {
   853        if (errorCount() > 0)
   876        if (shouldStop(CompileState.PARSE))
   854            return List.nil();
   877            return List.nil();
   855 
   878 
   856         //parse all files
   879         //parse all files
   857         ListBuffer<JCCompilationUnit> trees = lb();
   880         ListBuffer<JCCompilationUnit> trees = lb();
   858         for (JavaFileObject fileObject : fileObjects)
   881         for (JavaFileObject fileObject : fileObjects)
   959      * @return an instance of the compiler in which to complete the compilation
   982      * @return an instance of the compiler in which to complete the compilation
   960      */
   983      */
   961     public JavaCompiler processAnnotations(List<JCCompilationUnit> roots,
   984     public JavaCompiler processAnnotations(List<JCCompilationUnit> roots,
   962                                            List<String> classnames)
   985                                            List<String> classnames)
   963         throws IOException  { // TODO: see TEMP note in JavacProcessingEnvironment
   986         throws IOException  { // TODO: see TEMP note in JavacProcessingEnvironment
   964         if (errorCount() != 0) {
   987         if (shouldStop(CompileState.PROCESS)) {
   965             // Errors were encountered.  If todo is empty, then the
   988             // Errors were encountered.  If todo is empty, then the
   966             // encountered errors were parse errors.  Otherwise, the
   989             // encountered errors were parse errors.  Otherwise, the
   967             // errors were found during the enter phase which should
   990             // errors were found during the enter phase which should
   968             // be ignored when processing annotations.
   991             // be ignored when processing annotations.
   969 
   992 
  1066      */
  1089      */
  1067     public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) {
  1090     public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) {
  1068         ListBuffer<Env<AttrContext>> results = lb();
  1091         ListBuffer<Env<AttrContext>> results = lb();
  1069         while (!envs.isEmpty())
  1092         while (!envs.isEmpty())
  1070             results.append(attribute(envs.remove()));
  1093             results.append(attribute(envs.remove()));
  1071         return results;
  1094         return stopIfError(CompileState.ATTR, results);
  1072     }
  1095     }
  1073 
  1096 
  1074     /**
  1097     /**
  1075      * Attribute a parse tree.
  1098      * Attribute a parse tree.
  1076      * @returns the attributed parse tree
  1099      * @returns the attributed parse tree
  1113     public Queue<Env<AttrContext>> flow(Queue<Env<AttrContext>> envs) {
  1136     public Queue<Env<AttrContext>> flow(Queue<Env<AttrContext>> envs) {
  1114         ListBuffer<Env<AttrContext>> results = lb();
  1137         ListBuffer<Env<AttrContext>> results = lb();
  1115         for (Env<AttrContext> env: envs) {
  1138         for (Env<AttrContext> env: envs) {
  1116             flow(env, results);
  1139             flow(env, results);
  1117         }
  1140         }
  1118         return stopIfError(results);
  1141         return stopIfError(CompileState.FLOW, results);
  1119     }
  1142     }
  1120 
  1143 
  1121     /**
  1144     /**
  1122      * Perform dataflow checks on an attributed parse tree.
  1145      * Perform dataflow checks on an attributed parse tree.
  1123      */
  1146      */
  1124     public Queue<Env<AttrContext>> flow(Env<AttrContext> env) {
  1147     public Queue<Env<AttrContext>> flow(Env<AttrContext> env) {
  1125         ListBuffer<Env<AttrContext>> results = lb();
  1148         ListBuffer<Env<AttrContext>> results = lb();
  1126         flow(env, results);
  1149         flow(env, results);
  1127         return stopIfError(results);
  1150         return stopIfError(CompileState.FLOW, results);
  1128     }
  1151     }
  1129 
  1152 
  1130     /**
  1153     /**
  1131      * Perform dataflow checks on an attributed parse tree.
  1154      * Perform dataflow checks on an attributed parse tree.
  1132      */
  1155      */
  1133     protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
  1156     protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
  1134         try {
  1157         try {
  1135             if (errorCount() > 0)
  1158             if (shouldStop(CompileState.FLOW))
  1136                 return;
  1159                 return;
  1137 
  1160 
  1138             if (relax || compileStates.isDone(env, CompileState.FLOW)) {
  1161             if (relax || compileStates.isDone(env, CompileState.FLOW)) {
  1139                 results.add(env);
  1162                 results.add(env);
  1140                 return;
  1163                 return;
  1141             }
  1164             }
  1142 
  1165 
  1143             if (verboseCompilePolicy)
  1166             if (verboseCompilePolicy)
  1144                 log.printLines(log.noticeWriter, "[flow " + env.enclClass.sym + "]");
  1167                 printNote("[flow " + env.enclClass.sym + "]");
  1145             JavaFileObject prev = log.useSource(
  1168             JavaFileObject prev = log.useSource(
  1146                                                 env.enclClass.sym.sourcefile != null ?
  1169                                                 env.enclClass.sym.sourcefile != null ?
  1147                                                 env.enclClass.sym.sourcefile :
  1170                                                 env.enclClass.sym.sourcefile :
  1148                                                 env.toplevel.sourcefile);
  1171                                                 env.toplevel.sourcefile);
  1149             try {
  1172             try {
  1150                 make.at(Position.FIRSTPOS);
  1173                 make.at(Position.FIRSTPOS);
  1151                 TreeMaker localMake = make.forToplevel(env.toplevel);
  1174                 TreeMaker localMake = make.forToplevel(env.toplevel);
  1152                 flow.analyzeTree(env.tree, localMake);
  1175                 flow.analyzeTree(env.tree, localMake);
  1153                 compileStates.put(env, CompileState.FLOW);
  1176                 compileStates.put(env, CompileState.FLOW);
  1154 
  1177 
  1155                 if (errorCount() > 0)
  1178                 if (shouldStop(CompileState.FLOW))
  1156                     return;
  1179                     return;
  1157 
  1180 
  1158                 results.add(env);
  1181                 results.add(env);
  1159             }
  1182             }
  1160             finally {
  1183             finally {
  1177      */
  1200      */
  1178     public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
  1201     public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
  1179         ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = lb();
  1202         ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = lb();
  1180         for (Env<AttrContext> env: envs)
  1203         for (Env<AttrContext> env: envs)
  1181             desugar(env, results);
  1204             desugar(env, results);
  1182         return stopIfError(results);
  1205         return stopIfError(CompileState.FLOW, results);
  1183     }
  1206     }
  1184 
  1207 
  1185     /**
  1208     /**
  1186      * Prepare attributed parse trees, in conjunction with their attribution contexts,
  1209      * Prepare attributed parse trees, in conjunction with their attribution contexts,
  1187      * for source or code generation. If the file was not listed on the command line,
  1210      * for source or code generation. If the file was not listed on the command line,
  1188      * the current implicitSourcePolicy is taken into account.
  1211      * the current implicitSourcePolicy is taken into account.
  1189      * The preparation stops as soon as an error is found.
  1212      * The preparation stops as soon as an error is found.
  1190      */
  1213      */
  1191     protected void desugar(final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) {
  1214     protected void desugar(final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) {
  1192         if (errorCount() > 0)
  1215         if (shouldStop(CompileState.TRANSTYPES))
  1193             return;
  1216             return;
  1194 
  1217 
  1195         if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
  1218         if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
  1196                 && !inputFiles.contains(env.toplevel.sourcefile)) {
  1219                 && !inputFiles.contains(env.toplevel.sourcefile)) {
  1197             return;
  1220             return;
  1202          * including information in supertypes, we need to ensure that supertypes
  1225          * including information in supertypes, we need to ensure that supertypes
  1203          * are processed through attribute and flow before subtypes are translated.
  1226          * are processed through attribute and flow before subtypes are translated.
  1204          */
  1227          */
  1205         class ScanNested extends TreeScanner {
  1228         class ScanNested extends TreeScanner {
  1206             Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
  1229             Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
       
  1230             @Override
  1207             public void visitClassDef(JCClassDecl node) {
  1231             public void visitClassDef(JCClassDecl node) {
  1208                 Type st = types.supertype(node.sym.type);
  1232                 Type st = types.supertype(node.sym.type);
  1209                 if (st.tag == TypeTags.CLASS) {
  1233                 if (st.tag == TypeTags.CLASS) {
  1210                     ClassSymbol c = st.tsym.outermostClass();
  1234                     ClassSymbol c = st.tsym.outermostClass();
  1211                     Env<AttrContext> stEnv = enter.getEnv(c);
  1235                     Env<AttrContext> stEnv = enter.getEnv(c);
  1224                 flow(attribute(dep));
  1248                 flow(attribute(dep));
  1225         }
  1249         }
  1226 
  1250 
  1227         //We need to check for error another time as more classes might
  1251         //We need to check for error another time as more classes might
  1228         //have been attributed and analyzed at this stage
  1252         //have been attributed and analyzed at this stage
  1229         if (errorCount() > 0)
  1253         if (shouldStop(CompileState.TRANSTYPES))
  1230             return;
  1254             return;
  1231 
  1255 
  1232         if (verboseCompilePolicy)
  1256         if (verboseCompilePolicy)
  1233             log.printLines(log.noticeWriter, "[desugar " + env.enclClass.sym + "]");
  1257             printNote("[desugar " + env.enclClass.sym + "]");
  1234 
  1258 
  1235         JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
  1259         JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
  1236                                   env.enclClass.sym.sourcefile :
  1260                                   env.enclClass.sym.sourcefile :
  1237                                   env.toplevel.sourcefile);
  1261                                   env.toplevel.sourcefile);
  1238         try {
  1262         try {
  1242             make.at(Position.FIRSTPOS);
  1266             make.at(Position.FIRSTPOS);
  1243             TreeMaker localMake = make.forToplevel(env.toplevel);
  1267             TreeMaker localMake = make.forToplevel(env.toplevel);
  1244 
  1268 
  1245             if (env.tree instanceof JCCompilationUnit) {
  1269             if (env.tree instanceof JCCompilationUnit) {
  1246                 if (!(stubOutput || sourceOutput || printFlat)) {
  1270                 if (!(stubOutput || sourceOutput || printFlat)) {
       
  1271                     if (shouldStop(CompileState.LOWER))
       
  1272                         return;
  1247                     List<JCTree> pdef = lower.translateTopLevelClass(env, env.tree, localMake);
  1273                     List<JCTree> pdef = lower.translateTopLevelClass(env, env.tree, localMake);
  1248                     if (pdef.head != null) {
  1274                     if (pdef.head != null) {
  1249                         assert pdef.tail.isEmpty();
  1275                         assert pdef.tail.isEmpty();
  1250                         results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, (JCClassDecl)pdef.head));
  1276                         results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, (JCClassDecl)pdef.head));
  1251                     }
  1277                     }
  1264                     results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, removeMethodBodies(cdef)));
  1290                     results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, removeMethodBodies(cdef)));
  1265                 }
  1291                 }
  1266                 return;
  1292                 return;
  1267             }
  1293             }
  1268 
  1294 
       
  1295             if (shouldStop(CompileState.TRANSTYPES))
       
  1296                 return;
       
  1297 
  1269             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
  1298             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
  1270 
  1299 
  1271             if (errorCount() != 0)
  1300             if (shouldStop(CompileState.LOWER))
  1272                 return;
  1301                 return;
  1273 
  1302 
  1274             if (sourceOutput) {
  1303             if (sourceOutput) {
  1275                 //emit standard Java source file, only for compilation
  1304                 //emit standard Java source file, only for compilation
  1276                 //units enumerated explicitly on the command line
  1305                 //units enumerated explicitly on the command line
  1283             }
  1312             }
  1284 
  1313 
  1285             //translate out inner classes
  1314             //translate out inner classes
  1286             List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
  1315             List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
  1287 
  1316 
  1288             if (errorCount() != 0)
  1317             if (shouldStop(CompileState.LOWER))
  1289                 return;
  1318                 return;
  1290 
  1319 
  1291             //generate code for each class
  1320             //generate code for each class
  1292             for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
  1321             for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
  1293                 JCClassDecl cdef = (JCClassDecl)l.head;
  1322                 JCClassDecl cdef = (JCClassDecl)l.head;
  1308     public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue) {
  1337     public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue) {
  1309         generate(queue, null);
  1338         generate(queue, null);
  1310     }
  1339     }
  1311 
  1340 
  1312     public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, Queue<JavaFileObject> results) {
  1341     public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, Queue<JavaFileObject> results) {
       
  1342         if (shouldStop(CompileState.GENERATE))
       
  1343             return;
       
  1344 
  1313         boolean usePrintSource = (stubOutput || sourceOutput || printFlat);
  1345         boolean usePrintSource = (stubOutput || sourceOutput || printFlat);
  1314 
  1346 
  1315         for (Pair<Env<AttrContext>, JCClassDecl> x: queue) {
  1347         for (Pair<Env<AttrContext>, JCClassDecl> x: queue) {
  1316             Env<AttrContext> env = x.fst;
  1348             Env<AttrContext> env = x.fst;
  1317             JCClassDecl cdef = x.snd;
  1349             JCClassDecl cdef = x.snd;
  1318 
  1350 
  1319             if (verboseCompilePolicy) {
  1351             if (verboseCompilePolicy) {
  1320                 log.printLines(log.noticeWriter, "[generate "
  1352                 printNote("[generate "
  1321                                + (usePrintSource ? " source" : "code")
  1353                                + (usePrintSource ? " source" : "code")
  1322                                + " " + cdef.sym + "]");
  1354                                + " " + cdef.sym + "]");
  1323             }
  1355             }
  1324 
  1356 
  1325             if (taskListener != null) {
  1357             if (taskListener != null) {
  1369         }
  1401         }
  1370 
  1402 
  1371         JCClassDecl removeMethodBodies(JCClassDecl cdef) {
  1403         JCClassDecl removeMethodBodies(JCClassDecl cdef) {
  1372             final boolean isInterface = (cdef.mods.flags & Flags.INTERFACE) != 0;
  1404             final boolean isInterface = (cdef.mods.flags & Flags.INTERFACE) != 0;
  1373             class MethodBodyRemover extends TreeTranslator {
  1405             class MethodBodyRemover extends TreeTranslator {
       
  1406                 @Override
  1374                 public void visitMethodDef(JCMethodDecl tree) {
  1407                 public void visitMethodDef(JCMethodDecl tree) {
  1375                     tree.mods.flags &= ~Flags.SYNCHRONIZED;
  1408                     tree.mods.flags &= ~Flags.SYNCHRONIZED;
  1376                     for (JCVariableDecl vd : tree.params)
  1409                     for (JCVariableDecl vd : tree.params)
  1377                         vd.mods.flags &= ~Flags.FINAL;
  1410                         vd.mods.flags &= ~Flags.FINAL;
  1378                     tree.body = null;
  1411                     tree.body = null;
  1379                     super.visitMethodDef(tree);
  1412                     super.visitMethodDef(tree);
  1380                 }
  1413                 }
       
  1414                 @Override
  1381                 public void visitVarDef(JCVariableDecl tree) {
  1415                 public void visitVarDef(JCVariableDecl tree) {
  1382                     if (tree.init != null && tree.init.type.constValue() == null)
  1416                     if (tree.init != null && tree.init.type.constValue() == null)
  1383                         tree.init = null;
  1417                         tree.init = null;
  1384                     super.visitVarDef(tree);
  1418                     super.visitVarDef(tree);
  1385                 }
  1419                 }
       
  1420                 @Override
  1386                 public void visitClassDef(JCClassDecl tree) {
  1421                 public void visitClassDef(JCClassDecl tree) {
  1387                     ListBuffer<JCTree> newdefs = lb();
  1422                     ListBuffer<JCTree> newdefs = lb();
  1388                     for (List<JCTree> it = tree.defs; it.tail != null; it = it.tail) {
  1423                     for (List<JCTree> it = tree.defs; it.tail != null; it = it.tail) {
  1389                         JCTree t = it.head;
  1424                         JCTree t = it.head;
  1390                         switch (t.getTag()) {
  1425                         switch (t.getTag()) {
  1467                 names.dispose();
  1502                 names.dispose();
  1468             names = null;
  1503             names = null;
  1469         }
  1504         }
  1470     }
  1505     }
  1471 
  1506 
       
  1507     protected void printNote(String lines) {
       
  1508         Log.printLines(log.noticeWriter, lines);
       
  1509     }
       
  1510 
  1472     /** Output for "-verbose" option.
  1511     /** Output for "-verbose" option.
  1473      *  @param key The key to look up the correct internationalized string.
  1512      *  @param key The key to look up the correct internationalized string.
  1474      *  @param arg An argument for substitution into the output string.
  1513      *  @param arg An argument for substitution into the output string.
  1475      */
  1514      */
  1476     protected void printVerbose(String key, Object arg) {
  1515     protected void printVerbose(String key, Object arg) {
  1477         Log.printLines(log.noticeWriter, log.getLocalizedString("verbose." + key, arg));
  1516         Log.printLines(log.noticeWriter, Log.getLocalizedString("verbose." + key, arg));
  1478     }
  1517     }
  1479 
  1518 
  1480     /** Print numbers of errors and warnings.
  1519     /** Print numbers of errors and warnings.
  1481      */
  1520      */
  1482     protected void printCount(String kind, int count) {
  1521     protected void printCount(String kind, int count) {
  1483         if (count != 0) {
  1522         if (count != 0) {
  1484             String text;
  1523             String text;
  1485             if (count == 1)
  1524             if (count == 1)
  1486                 text = log.getLocalizedString("count." + kind, String.valueOf(count));
  1525                 text = Log.getLocalizedString("count." + kind, String.valueOf(count));
  1487             else
  1526             else
  1488                 text = log.getLocalizedString("count." + kind + ".plural", String.valueOf(count));
  1527                 text = Log.getLocalizedString("count." + kind + ".plural", String.valueOf(count));
  1489             Log.printLines(log.errWriter, text);
  1528             Log.printLines(log.errWriter, text);
  1490             log.errWriter.flush();
  1529             log.errWriter.flush();
  1491         }
  1530         }
  1492     }
  1531     }
  1493 
  1532