6988079: Errors reported via Messager.printMessage(ERROR,"error message") are not tallied correctly
Reviewed-by: darcy
This commit is contained in:
parent
d52a948474
commit
a4b1b99eb0
@ -820,13 +820,17 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
/** 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 priorWarnings) {
|
||||
private Round(Context context, int number, int priorErrors, int priorWarnings) {
|
||||
this.context = context;
|
||||
this.number = number;
|
||||
|
||||
compiler = JavaCompiler.instance(context);
|
||||
log = Log.instance(context);
|
||||
log.nerrors = priorErrors;
|
||||
log.nwarnings += priorWarnings;
|
||||
log.deferDiagnostics = true;
|
||||
|
||||
@ -840,7 +844,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
|
||||
/** Create the first round. */
|
||||
Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) {
|
||||
this(context, 1, 0);
|
||||
this(context, 1, 0, 0);
|
||||
this.roots = roots;
|
||||
genClassFiles = new HashMap<String,JavaFileObject>();
|
||||
|
||||
@ -860,7 +864,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
/** Create a new round. */
|
||||
private Round(Round prev,
|
||||
Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
|
||||
this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
|
||||
this(prev.nextContext(),
|
||||
prev.number+1,
|
||||
prev.nMessagerErrors,
|
||||
prev.compiler.log.nwarnings);
|
||||
this.genClassFiles = prev.genClassFiles;
|
||||
|
||||
List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
|
||||
@ -1014,6 +1021,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
if (taskListener != null)
|
||||
taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
|
||||
}
|
||||
|
||||
nMessagerErrors = messager.errorCount();
|
||||
}
|
||||
|
||||
void showDiagnostics(boolean showAll) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
SemanticErrorTest.java:11:46: compiler.err.repeated.interface
|
||||
- compiler.err.proc.messager: Deliberate Error
|
||||
SemanticErrorTest.java:11:46: compiler.err.repeated.interface
|
||||
1 error
|
||||
2 errors
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6988079
|
||||
* @summary Errors reported via Messager.printMessage(ERROR,"error message") are not tallied correctly
|
||||
* @library ../../lib
|
||||
* @build JavacTestingAbstractProcessor TestErrorCount
|
||||
* @compile/fail/ref=TestErrorCount.out -XDrawDiagnostics -processor TestErrorCount TestErrorCount.java
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.tools.*;
|
||||
|
||||
public class TestErrorCount extends JavacTestingAbstractProcessor {
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "intentional error");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
- compiler.err.proc.messager: intentional error
|
||||
- compiler.err.proc.messager: intentional error
|
||||
2 errors
|
Loading…
Reference in New Issue
Block a user