< prev index next >

langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java

Print this page




 875      * discovery, {@code null} means that no processors were provided
 876      */
 877     public void compile(Collection<JavaFileObject> sourceFileObjects,
 878                         Collection<String> classnames,
 879                         Iterable<? extends Processor> processors)
 880     {
 881         if (!taskListener.isEmpty()) {
 882             taskListener.started(new TaskEvent(TaskEvent.Kind.COMPILATION));
 883         }
 884 
 885         if (processors != null && processors.iterator().hasNext())
 886             explicitAnnotationProcessingRequested = true;
 887         // as a JavaCompiler can only be used once, throw an exception if
 888         // it has been used before.
 889         if (hasBeenUsed)
 890             checkReusable();
 891         hasBeenUsed = true;
 892 
 893         // forcibly set the equivalent of -Xlint:-options, so that no further
 894         // warnings about command line options are generated from this point on
 895         options.put(XLINT_CUSTOM.text + "-" + LintCategory.OPTIONS.option, "true");
 896         options.remove(XLINT_CUSTOM.text + LintCategory.OPTIONS.option);
 897 
 898         start_msec = now();
 899 
 900         try {
 901             initProcessAnnotations(processors);
 902 
 903             // These method calls must be chained to avoid memory leaks
 904             processAnnotations(
 905                 enterTrees(
 906                         stopIfError(CompileState.PARSE,
 907                                 initModules(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))))
 908                 ),
 909                 classnames
 910             );
 911 
 912             // If it's safe to do so, skip attr / flow / gen for implicit classes
 913             if (taskListener.isEmpty() &&
 914                     implicitSourcePolicy == ImplicitSourcePolicy.NONE) {
 915                 todo.retainFiles(inputFiles);
 916             }


1241 
1242     private boolean unrecoverableError() {
1243         if (deferredDiagnosticHandler != null) {
1244             for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
1245                 if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE))
1246                     return true;
1247             }
1248         }
1249         return false;
1250     }
1251 
1252     boolean explicitAnnotationProcessingRequested() {
1253         return
1254             explicitAnnotationProcessingRequested ||
1255             explicitAnnotationProcessingRequested(options);
1256     }
1257 
1258     static boolean explicitAnnotationProcessingRequested(Options options) {
1259         return
1260             options.isSet(PROCESSOR) ||
1261             options.isSet(PROCESSORPATH) ||
1262             options.isSet(PROCESSORMODULEPATH) ||
1263             options.isSet(PROC, "only") ||
1264             options.isSet(XPRINT);
1265     }
1266 
1267     public void setDeferredDiagnosticHandler(Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
1268         this.deferredDiagnosticHandler = deferredDiagnosticHandler;
1269     }
1270 
1271     /**
1272      * Attribute a list of parse trees, such as found on the "todo" list.
1273      * Note that attributing classes may cause additional files to be
1274      * parsed and entered via the SourceCompleter.
1275      * Attribution of the entries in the list does not stop if any errors occur.
1276      * @return a list of environments for attribute classes.
1277      */
1278     public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) {
1279         ListBuffer<Env<AttrContext>> results = new ListBuffer<>();
1280         while (!envs.isEmpty())
1281             results.append(attribute(envs.remove()));
1282         return stopIfError(CompileState.ATTR, results);




 875      * discovery, {@code null} means that no processors were provided
 876      */
 877     public void compile(Collection<JavaFileObject> sourceFileObjects,
 878                         Collection<String> classnames,
 879                         Iterable<? extends Processor> processors)
 880     {
 881         if (!taskListener.isEmpty()) {
 882             taskListener.started(new TaskEvent(TaskEvent.Kind.COMPILATION));
 883         }
 884 
 885         if (processors != null && processors.iterator().hasNext())
 886             explicitAnnotationProcessingRequested = true;
 887         // as a JavaCompiler can only be used once, throw an exception if
 888         // it has been used before.
 889         if (hasBeenUsed)
 890             checkReusable();
 891         hasBeenUsed = true;
 892 
 893         // forcibly set the equivalent of -Xlint:-options, so that no further
 894         // warnings about command line options are generated from this point on
 895         options.put(XLINT_CUSTOM.primaryName + "-" + LintCategory.OPTIONS.option, "true");
 896         options.remove(XLINT_CUSTOM.primaryName + LintCategory.OPTIONS.option);
 897 
 898         start_msec = now();
 899 
 900         try {
 901             initProcessAnnotations(processors);
 902 
 903             // These method calls must be chained to avoid memory leaks
 904             processAnnotations(
 905                 enterTrees(
 906                         stopIfError(CompileState.PARSE,
 907                                 initModules(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))))
 908                 ),
 909                 classnames
 910             );
 911 
 912             // If it's safe to do so, skip attr / flow / gen for implicit classes
 913             if (taskListener.isEmpty() &&
 914                     implicitSourcePolicy == ImplicitSourcePolicy.NONE) {
 915                 todo.retainFiles(inputFiles);
 916             }


1241 
1242     private boolean unrecoverableError() {
1243         if (deferredDiagnosticHandler != null) {
1244             for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
1245                 if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE))
1246                     return true;
1247             }
1248         }
1249         return false;
1250     }
1251 
1252     boolean explicitAnnotationProcessingRequested() {
1253         return
1254             explicitAnnotationProcessingRequested ||
1255             explicitAnnotationProcessingRequested(options);
1256     }
1257 
1258     static boolean explicitAnnotationProcessingRequested(Options options) {
1259         return
1260             options.isSet(PROCESSOR) ||
1261             options.isSet(PROCESSOR_PATH) ||
1262             options.isSet(PROCESSOR_MODULE_PATH) ||
1263             options.isSet(PROC, "only") ||
1264             options.isSet(XPRINT);
1265     }
1266 
1267     public void setDeferredDiagnosticHandler(Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
1268         this.deferredDiagnosticHandler = deferredDiagnosticHandler;
1269     }
1270 
1271     /**
1272      * Attribute a list of parse trees, such as found on the "todo" list.
1273      * Note that attributing classes may cause additional files to be
1274      * parsed and entered via the SourceCompleter.
1275      * Attribution of the entries in the list does not stop if any errors occur.
1276      * @return a list of environments for attribute classes.
1277      */
1278     public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) {
1279         ListBuffer<Env<AttrContext>> results = new ListBuffer<>();
1280         while (!envs.isEmpty())
1281             results.append(attribute(envs.remove()));
1282         return stopIfError(CompileState.ATTR, results);


< prev index next >