changeset 1906:8466f6bcab55

Clean up error propagation between rounds. Remove complications in JavacProcessingEnvironment and propagate nerrors and nwarnings in Log. Only a few test cases needed to be adapted to the correct behavior.
author wmdietl
date Mon, 19 Nov 2012 01:59:08 -0800
parents 4513dfa84ded
children 3002422758f3
files src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java src/share/classes/com/sun/tools/javac/util/Log.java test/tools/javac/7129225/TestImportStar.java test/tools/javac/7129225/TestImportStar.ref test/tools/javac/processing/6994946/SemanticErrorTest.2.out test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.ref
diffstat 9 files changed, 62 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Nov 19 01:52:55 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Nov 19 01:59:08 2012 -0800
@@ -794,9 +794,6 @@
         /** The set of package-info files to be processed this round. */
         List<PackageSymbol> packageInfoFiles;
 
-        /** The number of Messager errors generated in this round. */
-        int nMessagerErrors;
-
         /** Create a round (common code). */
         private Round(Context context, int number, int priorErrors, int priorWarnings) {
             this.context = context;
@@ -805,7 +802,7 @@
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
             log.nerrors = priorErrors;
-            log.nwarnings += priorWarnings;
+            log.nwarnings = priorWarnings;
             log.deferAll();
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
@@ -840,7 +837,7 @@
                 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
             this(prev.nextContext(),
                     prev.number+1,
-                    prev.nMessagerErrors,
+                    prev.compiler.log.nerrors,
                     prev.compiler.log.nwarnings);
             this.genClassFiles = prev.genClassFiles;
 
@@ -880,15 +877,12 @@
         }
 
         /** Create the compiler to be used for the final compilation. */
-        JavaCompiler finalCompiler(boolean errorStatus) {
+        JavaCompiler finalCompiler() {
             try {
                 Context nextCtx = nextContext();
                 JavacProcessingEnvironment.this.context = nextCtx;
                 JavaCompiler c = JavaCompiler.instance(nextCtx);
-                c.log.nwarnings += compiler.log.nwarnings;
-                if (errorStatus) {
-                    c.log.nerrors += compiler.log.nerrors;
-                }
+                c.log.initRound(compiler.log);
                 return c;
             } finally {
                 compiler.close(false);
@@ -996,8 +990,6 @@
                 if (!taskListener.isEmpty())
                     taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
             }
-
-            nMessagerErrors = messager.errorCount();
         }
 
         void showDiagnostics(boolean showAll) {
@@ -1171,7 +1163,7 @@
                 new LinkedHashSet<JavaFileObject>(filer.getGeneratedSourceFileObjects());
         roots = cleanTrees(round.roots);
 
-        JavaCompiler compiler = round.finalCompiler(errorStatus);
+        JavaCompiler compiler = round.finalCompiler();
 
         if (newSourceFiles.size() > 0)
             roots = roots.appendList(compiler.parseFiles(newSourceFiles));
--- a/src/share/classes/com/sun/tools/javac/util/Log.java	Mon Nov 19 01:52:55 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Mon Nov 19 01:59:08 2012 -0800
@@ -304,10 +304,8 @@
         this.errWriter = other.errWriter;
         this.sourceMap = other.sourceMap;
         this.recorded = other.recorded;
-        // TODO: with this, the errors in Flow go away, e.g tools/javac/api/6406133/
-        // But it also causes problems with error counts, e.g. tools/javac/7129225/
-        // I propose we keep this and work on the test cases.
         this.nerrors = other.nerrors;
+        this.nwarnings = other.nwarnings;
     }
 
     /** Flush the logs
--- a/test/tools/javac/7129225/TestImportStar.java	Mon Nov 19 01:52:55 2012 -0800
+++ b/test/tools/javac/7129225/TestImportStar.java	Mon Nov 19 01:59:08 2012 -0800
@@ -30,7 +30,7 @@
  * @build JavacTestingAbstractProcessor
  * @compile/fail/ref=NegTest.ref -XDrawDiagnostics TestImportStar.java
  * @compile Anno.java AnnoProcessor.java
- * @compile/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java
+ * @compile/fail/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java
  */
 
  //The @compile/fail... verifies that the fix doesn't break the normal compilation of import xxx.*
--- a/test/tools/javac/7129225/TestImportStar.ref	Mon Nov 19 01:52:55 2012 -0800
+++ b/test/tools/javac/7129225/TestImportStar.ref	Mon Nov 19 01:59:08 2012 -0800
@@ -1,3 +1,4 @@
 - compiler.note.proc.messager: RUNNING - lastRound = false
 TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx
 - compiler.note.proc.messager: RUNNING - lastRound = true
+1 error
\ No newline at end of file
--- a/test/tools/javac/processing/6994946/SemanticErrorTest.2.out	Mon Nov 19 01:52:55 2012 -0800
+++ b/test/tools/javac/processing/6994946/SemanticErrorTest.2.out	Mon Nov 19 01:59:08 2012 -0800
@@ -1,4 +1,3 @@
 SemanticErrorTest.java:11:46: compiler.err.repeated.interface
 - compiler.err.proc.messager: Deliberate Error
-SemanticErrorTest.java:11:46: compiler.err.repeated.interface
-2 errors
+2 errors
\ No newline at end of file
--- a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java	Mon Nov 19 01:52:55 2012 -0800
+++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java	Mon Nov 19 01:59:08 2012 -0800
@@ -28,7 +28,7 @@
  * @summary Modeling type implementing missing interfaces
  * @library ../../../../lib
  * @build JavacTestingAbstractProcessor TestMissingElement
- * @compile -proc:only -XprintRounds -processor TestMissingElement InvalidSource.java
+ * @compile/fail/ref=TestMissingElement.ref -proc:only -XprintRounds -XDrawDiagnostics -processor TestMissingElement InvalidSource.java
  */
 
 import java.util.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref	Mon Nov 19 01:59:08 2012 -0800
@@ -0,0 +1,49 @@
+Round 1:
+	input files: {ExpectInterfaces, ExpectSupertype, OK, InvalidSource}
+	annotations: [ExpectSupertype, ExpectInterfaces]
+	last round: false
+Round 2:
+	input files: {}
+	annotations: []
+	last round: true
+InvalidSource.java:55:42: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:58:44: compiler.err.doesnt.exist: A
+InvalidSource.java:61:54: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.package, java.util, null)
+InvalidSource.java:64:47: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:67:44: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:70:46: compiler.err.doesnt.exist: A
+InvalidSource.java:73:55: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:76:59: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:79:46: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:79:49: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:82:44: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:85:46: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:88:50: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:91:45: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:91:48: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:94:49: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:97:51: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:97:57: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:100:49: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:103:51: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:103:57: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:106:58: compiler.err.cant.resolve.location: kindname.class, X, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+22 errors
+check supertype: InvalidSource.TestClassMissingClassA -- !:empty clss A!
+check supertype: InvalidSource.TestClassMissingClassAB -- !:empty clss (pkg A).B!
+check supertype: InvalidSource.TestClassMissingClass_juA -- !:empty clss (pkg java.util).A!
+check supertype: InvalidSource.TestClassTMissingClassAT -- !:empty clss A!<tvar T>
+check interfaces: InvalidSource.TestClassMissingIntfA -- !:empty intf A!
+check interfaces: InvalidSource.TestClassMissingIntfAB -- !:empty intf (pkg A).B!
+check interfaces: InvalidSource.TestClassMissingIntfAOK -- !:empty intf A!, intf OK
+check interfaces: InvalidSource.TestClassOKMissingIntfA -- intf OK, !:empty intf A!
+check interfaces: InvalidSource.TestClassMissingIntfA_B -- !:empty intf A!, !:empty intf B!
+check interfaces: InvalidSource.TestIntfMissingIntfA -- !:empty intf A!
+check interfaces: InvalidSource.TestIntfMissingIntfAOK -- !:empty intf A!, intf OK
+check interfaces: InvalidSource.TestIntfOKMissingIntfA -- intf OK, !:empty intf A!
+check interfaces: InvalidSource.TestIntfMissingIntfAB -- !:empty intf A!, !:empty intf B!
+check interfaces: InvalidSource.TestClassTMissingIntfAT -- !:empty intf A!<tvar T>
+check interfaces: InvalidSource.TestClassTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B!
+check interfaces: InvalidSource.TestIntfTMissingIntfAT -- !:empty intf A!<tvar T>
+check interfaces: InvalidSource.TestIntfTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B!
+check interfaces: InvalidSource.TestClassListMissingX -- intf (pkg java.util).List<!:empty clss X!>
\ No newline at end of file
--- a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java	Mon Nov 19 01:52:55 2012 -0800
+++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java	Mon Nov 19 01:59:08 2012 -0800
@@ -28,7 +28,7 @@
  * @author  Scott Seligman
  * @library ../../../../lib
  * @build   JavacTestingAbstractProcessor DirectSupersOfErr
- * @compile -processor DirectSupersOfErr -proc:only C1.java
+ * @compile/fail/ref=DirectSupersOfErr.ref -processor DirectSupersOfErr -proc:only -XDrawDiagnostics C1.java
  */
 
 import java.util.Set;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.ref	Mon Nov 19 01:59:08 2012 -0800
@@ -0,0 +1,2 @@
+C1.java:24:18: compiler.err.cant.resolve: kindname.class, Bogus, , 
+1 error