6511613: javac unexpectedly doesn't fail in some cases if an annotation processor specified
authorjjg
Tue, 23 Feb 2010 18:43:02 -0800
changeset 5001 71ed0cc22974
parent 4941 37df21e3fdb7
child 5002 12a9e8562200
6511613: javac unexpectedly doesn't fail in some cases if an annotation processor specified Reviewed-by: darcy
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
langtools/src/share/classes/com/sun/tools/javac/util/Log.java
langtools/test/tools/javac/processing/6511613/DummyProcessor.java
langtools/test/tools/javac/processing/6511613/clss41701.java
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Feb 22 21:37:13 2010 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Feb 23 18:43:02 2010 -0800
@@ -2636,6 +2636,7 @@
                 if (tree.bounds.tail.nonEmpty()) {
                     log.error(tree.bounds.tail.head.pos(),
                               "type.var.may.not.be.followed.by.other.bounds");
+                    log.unrecoverableError = true;
                     tree.bounds = List.of(tree.bounds.head);
                     a.bound = bs.head;
                 }
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Feb 22 21:37:13 2010 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Feb 23 18:43:02 2010 -0800
@@ -549,12 +549,6 @@
             return log.nwarnings;
     }
 
-    /** Whether or not any parse errors have occurred.
-     */
-    public boolean parseErrors() {
-        return parseErrors;
-    }
-
     /** Try to open input stream with given name.
      *  Report an error if this fails.
      *  @param filename   The file name of the input stream to be opened.
@@ -588,7 +582,7 @@
             int initialErrorCount = log.nerrors;
             Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
             tree = parser.parseCompilationUnit();
-            parseErrors |= (log.nerrors > initialErrorCount);
+            log.unrecoverableError |= (log.nerrors > initialErrorCount);
             if (verbose) {
                 printVerbose("parsing.done", Long.toString(elapsed(msec)));
             }
@@ -768,9 +762,6 @@
     private long start_msec = 0;
     public long elapsed_msec = 0;
 
-    /** Track whether any errors occurred while parsing source text. */
-    private boolean parseErrors = false;
-
     public void compile(List<JavaFileObject> sourceFileObject)
         throws Throwable {
         compile(sourceFileObject, List.<String>nil(), null);
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Feb 22 21:37:13 2010 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Feb 23 18:43:02 2010 -0800
@@ -878,7 +878,7 @@
                     roots = cleanTrees(roots).appendList(parsedFiles);
 
                     // Check for errors after parsing
-                    if (compiler.parseErrors()) {
+                    if (log.unrecoverableError) {
                         errorStatus = true;
                         break runAround;
                     } else {
@@ -912,7 +912,7 @@
         roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener);
         // Set error status for any files compiled and generated in
         // the last round
-        if (compiler.parseErrors())
+        if (log.unrecoverableError)
             errorStatus = true;
 
         compiler.close(false);
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Mon Feb 22 21:37:13 2010 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Tue Feb 23 18:43:02 2010 -0800
@@ -192,6 +192,12 @@
      */
     public int nwarnings = 0;
 
+    /**
+     * Whether or not an unrecoverable error has been seen.
+     * Unrecoverable errors prevent subsequent annotation processing.
+     */
+    public boolean unrecoverableError;
+
     /** A set of all errors generated so far. This is used to avoid printing an
      *  error message more than once. For each error, a pair consisting of the
      *  source file name and source code position of the error is added to the set.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6511613/DummyProcessor.java	Tue Feb 23 18:43:02 2010 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import java.util.Set;
+
+@SupportedAnnotationTypes("*")
+public class DummyProcessor extends  AbstractProcessor {
+   public boolean process(Set<? extends TypeElement> annotations,
+                  RoundEnvironment roundEnv) {
+       return true;
+   }
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6511613/clss41701.java	Tue Feb 23 18:43:02 2010 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6511613
+ * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified
+ *
+ * @build DummyProcessor
+ * @compile/fail clss41701.java
+ * @compile/fail -processor DummyProcessor clss41701.java
+ */
+
+import java.io.PrintStream;
+
+interface clss41701i {
+    void run();
+}
+
+class clss41701a<A extends clss41701i,
+                 B extends clss41701i,
+                 C extends A&B> {
+}