Wed, 02 Mar 2011 21:06:17 -0800
6986892: confusing warning given after errors in annotation processing
Reviewed-by: darcy
1.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Mar 02 14:03:38 2011 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Mar 02 21:06:17 2011 -0800 1.3 @@ -1520,7 +1520,8 @@ 1.4 } 1.5 1.6 public void reportDeferredDiagnostics() { 1.7 - if (annotationProcessingOccurred 1.8 + if (errorCount() == 0 1.9 + && annotationProcessingOccurred 1.10 && implicitSourceFilesRead 1.11 && implicitSourcePolicy == ImplicitSourcePolicy.UNSET) { 1.12 if (explicitAnnotationProcessingRequested())
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/C1.java Wed Mar 02 21:06:17 2011 -0800 2.3 @@ -0,0 +1,24 @@ 2.4 +/* 2.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +class C1 extends p.C2 { }
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java Wed Mar 02 21:06:17 2011 -0800 3.3 @@ -0,0 +1,59 @@ 3.4 +/* 3.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/* 3.28 + * @test 3.29 + * @bug 6986892 3.30 + * @summary confusing warning given after errors in annotation processing 3.31 + * @library ../../../lib 3.32 + * @build JavacTestingAbstractProcessor TestProcUseImplicitWarning 3.33 + * @clean C1 p.C2 3.34 + * @compile/fail/ref=err.out -XDrawDiagnostics -processor TestProcUseImplicitWarning -Aerror C1.java 3.35 + * @clean C1 p.C2 3.36 + * @compile/ref=warn.out -XDrawDiagnostics -processor TestProcUseImplicitWarning C1.java 3.37 + */ 3.38 + 3.39 +import java.util.*; 3.40 +import javax.annotation.processing.*; 3.41 +import javax.lang.model.element.*; 3.42 +import static javax.tools.Diagnostic.Kind.*; 3.43 + 3.44 +@SupportedOptions("error") 3.45 +public class TestProcUseImplicitWarning extends JavacTestingAbstractProcessor { 3.46 + 3.47 + int round = 0; 3.48 + 3.49 + @Override 3.50 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 3.51 + round++; 3.52 + 3.53 + if (round == 1) { 3.54 + boolean error = options.containsKey("error"); 3.55 + if (error) 3.56 + messager.printMessage(ERROR, "error generated per option"); 3.57 + } 3.58 + 3.59 + return false; 3.60 + } 3.61 + 3.62 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/err.out Wed Mar 02 21:06:17 2011 -0800 4.3 @@ -0,0 +1,2 @@ 4.4 +- compiler.err.proc.messager: error generated per option 4.5 +1 error
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/p/C2.java Wed Mar 02 21:06:17 2011 -0800 5.3 @@ -0,0 +1,26 @@ 5.4 +/* 5.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + */ 5.26 + 5.27 +package p; 5.28 + 5.29 +public class C2 { }
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/tools/javac/processing/warnings/UseImplicit/warn.out Wed Mar 02 21:06:17 2011 -0800 6.3 @@ -0,0 +1,2 @@ 6.4 +- compiler.warn.proc.use.implicit 6.5 +1 warning