changeset 73:9f8c49401ccc

6511613: javac unexpectedly doesn't fail in some cases if an annotation processor specified Reviewed-by: darcy
author jjg
date Wed, 24 Feb 2010 13:34:15 -0800
parents 970e9ffbd931
children f7bc75dcef2c
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java src/share/classes/com/sun/tools/javac/util/Log.java test/tools/javac/processing/6511613/DummyProcessor.java test/tools/javac/processing/6511613/clss41701.java
diffstat 6 files changed, 94 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Feb 15 18:20:57 2010 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Feb 24 13:34:15 2010 -0800
@@ -2522,6 +2522,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);
                 }
             } else {
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Feb 15 18:20:57 2010 -0800
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Feb 24 13:34:15 2010 -0800
@@ -477,12 +477,6 @@
             return log.nwarnings;
     }
 
-    /** Whether or not any parse errors have occurred.
-     */
-    public boolean parseErrors() {
-        return parseErrors;
-    }
-
     protected Scanner.Factory getScannerFactory() {
         return Scanner.Factory.instance(context);
     }
@@ -521,7 +515,7 @@
             Scanner scanner = getScannerFactory().newScanner(content);
             Parser parser = parserFactory.newParser(scanner, keepComments(), genEndPos);
             tree = parser.compilationUnit();
-            parseErrors |= (log.nerrors > initialErrorCount);
+            log.unrecoverableError |= (log.nerrors > initialErrorCount);
             if (lineDebugInfo) {
                 tree.lineMap = scanner.getLineMap();
             }
@@ -704,9 +698,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/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Feb 15 18:20:57 2010 -0800
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Feb 24 13:34:15 2010 -0800
@@ -838,7 +838,7 @@
                     roots = cleanTrees(roots).appendList(parsedFiles);
 
                     // Check for errors after parsing
-                    if (compiler.parseErrors()) {
+                    if (log.unrecoverableError) {
                         errorStatus = true;
                         break runAround;
                     } else {
@@ -866,7 +866,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/src/share/classes/com/sun/tools/javac/util/Log.java	Mon Feb 15 18:20:57 2010 -0800
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Wed Feb 24 13:34:15 2010 -0800
@@ -183,6 +183,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/test/tools/javac/processing/6511613/DummyProcessor.java	Wed Feb 24 13:34:15 2010 -0800
@@ -0,0 +1,41 @@
+/*
+ * 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("*")
+@SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6)
+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/test/tools/javac/processing/6511613/clss41701.java	Wed Feb 24 13:34:15 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> {
+}