8273157: Add convenience methods to Messager
Reviewed-by: jjg
This commit is contained in:
parent
9689f61520
commit
2f01a6f8b6
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, 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
|
||||
@ -39,7 +39,8 @@ import javax.lang.model.element.*;
|
||||
* javax.tools.Diagnostic.Kind#ERROR error kind} will {@linkplain
|
||||
* RoundEnvironment#errorRaised raise an error}.
|
||||
*
|
||||
* <p>Note that the messages "printed" by methods in this
|
||||
* @apiNote
|
||||
* The messages "printed" by methods in this
|
||||
* interface may or may not appear as textual output to a location
|
||||
* like {@link System#out} or {@link System#err}. Implementations may
|
||||
* choose to present this information in a different fashion, such as
|
||||
@ -97,4 +98,90 @@ public interface Messager {
|
||||
Element e,
|
||||
AnnotationMirror a,
|
||||
AnnotationValue v);
|
||||
/**
|
||||
* Prints an error.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to {@code
|
||||
* printMessage(Diagnostic.Kind.ERROR, msg)}.
|
||||
*
|
||||
* @param msg the message, or an empty string if none
|
||||
* @since 18
|
||||
*/
|
||||
default void printError(CharSequence msg) {
|
||||
printMessage(Diagnostic.Kind.ERROR, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an error at the location of the element.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to {@code
|
||||
* printMessage(Diagnostic.Kind.ERROR, msg, e)}.
|
||||
*
|
||||
* @param msg the message, or an empty string if none
|
||||
* @param e the element to use as a position hint
|
||||
* @since 18
|
||||
*/
|
||||
default void printError(CharSequence msg, Element e) {
|
||||
printMessage(Diagnostic.Kind.ERROR, msg, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to {@code
|
||||
* printMessage(Diagnostic.Kind.WARNING, msg)}.
|
||||
*
|
||||
* @param msg the message, or an empty string if none
|
||||
* @since 18
|
||||
*/
|
||||
default void printWarning(CharSequence msg) {
|
||||
printMessage(Diagnostic.Kind.WARNING, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning at the location of the element.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to {@code
|
||||
* printMessage(Diagnostic.Kind.WARNING, msg, e)}.
|
||||
*
|
||||
* @param msg the message, or an empty string if none
|
||||
* @param e the element to use as a position hint
|
||||
* @since 18
|
||||
*/
|
||||
default void printWarning(CharSequence msg, Element e) {
|
||||
printMessage(Diagnostic.Kind.WARNING, msg, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a note.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to {@code
|
||||
* printMessage(Diagnostic.Kind.NOTE, msg)}.
|
||||
*
|
||||
* @param msg the message, or an empty string if none
|
||||
* @since 18
|
||||
*/
|
||||
default void printNote(CharSequence msg) {
|
||||
printMessage(Diagnostic.Kind.NOTE, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a note at the location of the element.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation is equivalent to {@code
|
||||
* printMessage(Diagnostic.Kind.NOTE, msg, e)}.
|
||||
*
|
||||
* @param msg the message, or an empty string if none
|
||||
* @param e the element to use as a position hint
|
||||
* @since 18
|
||||
*/
|
||||
default void printNote(CharSequence msg, Element e) {
|
||||
printMessage(Diagnostic.Kind.NOTE, msg, e);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, 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
|
||||
@ -25,7 +25,6 @@ import java.util.Set;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
@SupportedAnnotationTypes("Anno")
|
||||
public class AnnoProcessor extends JavacTestingAbstractProcessor {
|
||||
@ -36,7 +35,7 @@ public class AnnoProcessor extends JavacTestingAbstractProcessor {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> set, RoundEnvironment re) {
|
||||
messager.printMessage(Kind.NOTE, "RUNNING - lastRound = " + re.processingOver());
|
||||
messager.printNote("RUNNING - lastRound = " + re.processingOver());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
@SupportedAnnotationTypes("MethodParameterProcessor.ParameterNames")
|
||||
public class MethodParameterProcessor extends JavacTestingAbstractProcessor {
|
||||
@ -52,7 +51,7 @@ public class MethodParameterProcessor extends JavacTestingAbstractProcessor {
|
||||
for (Element element : roundEnv.getElementsAnnotatedWith(ParameterNames.class)) {
|
||||
ExecutableElement exec = (ExecutableElement)element;
|
||||
String message = printNamesAndAnnotations(exec);
|
||||
messager.printMessage(Kind.NOTE, message);
|
||||
messager.printNote(message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -90,9 +90,8 @@ public class T6406771 extends AbstractProcessor {
|
||||
return null;
|
||||
int expect = Integer.parseInt(s.substring(prefix.length()));
|
||||
if (expect != found) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Error: " + prefix + " pos=" + pos
|
||||
+ " expect=" + expect + " found=" + found);
|
||||
messager.printError("Error: " + prefix + " pos=" + pos
|
||||
+ " expect=" + expect + " found=" + found);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -26,7 +26,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
public class MyProcessor extends AbstractProcessor {
|
||||
@ -40,8 +39,7 @@ public class MyProcessor extends AbstractProcessor {
|
||||
for(TypeElement e : ElementFilter.typesIn(renv.getRootElements())) {
|
||||
for (TypeParameterElement tp : e.getTypeParameters()) {
|
||||
if (tp.getSimpleName().toString().length() > 1) {
|
||||
messager.printMessage(WARNING,
|
||||
"Type param names should be of length 1", tp);
|
||||
messager.printWarning("Type param names should be of length 1", tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -77,7 +77,7 @@ public class T7159016 {
|
||||
if (roundEnv.processingOver() || written++ > 0) {
|
||||
return false;
|
||||
}
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, "writing Generated.java");
|
||||
messager.printNote("writing Generated.java");
|
||||
try {
|
||||
Writer w = processingEnv.getFiler().createSourceFile("p.Generated").openWriter();
|
||||
try {
|
||||
@ -86,7 +86,7 @@ public class T7159016 {
|
||||
w.close();
|
||||
}
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, x.toString());
|
||||
messager.printError(x.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -86,7 +85,7 @@ public class ParameterProcessor extends JavacTestingAbstractProcessor {
|
||||
String.format(
|
||||
"bad parameter names for %s#%s; expected: %s, was: %s",
|
||||
element, element, expected, actual);
|
||||
messager.printMessage(Kind.ERROR, message);
|
||||
messager.printError(message);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -73,13 +73,13 @@ public class T6412669 extends AbstractProcessor {
|
||||
Trees trees = Trees.instance(processingEnv);
|
||||
SourcePositions sp = trees.getSourcePositions();
|
||||
Messager m = processingEnv.getMessager();
|
||||
m.printMessage(Diagnostic.Kind.NOTE, "processing annotations");
|
||||
m.printNote("processing annotations");
|
||||
int count = 0;
|
||||
for (TypeElement anno: annotations) {
|
||||
count++;
|
||||
m.printMessage(Diagnostic.Kind.NOTE, " processing annotation " + anno);
|
||||
m.printNote(" processing annotation " + anno);
|
||||
for (Element e: roundEnv.getElementsAnnotatedWith(anno)) {
|
||||
m.printMessage(Diagnostic.Kind.NOTE, " processing element " + e);
|
||||
m.printNote(" processing element " + e);
|
||||
TreePath p = trees.getPath(e);
|
||||
long start = sp.getStartPosition(p.getCompilationUnit(), p.getLeaf());
|
||||
long end = sp.getEndPosition(p.getCompilationUnit(), p.getLeaf());
|
||||
@ -89,7 +89,7 @@ public class T6412669 extends AbstractProcessor {
|
||||
}
|
||||
}
|
||||
if (count == 0)
|
||||
m.printMessage(Diagnostic.Kind.NOTE, "no annotations found");
|
||||
m.printNote("no annotations found");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -278,8 +278,8 @@ public class TestClientCodeWrapper extends JavacTestingAbstractProcessor {
|
||||
f4.getNestingKind();
|
||||
f4.getAccessLevel();
|
||||
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, "informational note",
|
||||
roundEnv.getRootElements().iterator().next());
|
||||
messager.printNote("informational note",
|
||||
roundEnv.getRootElements().iterator().next());
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new UserError(e);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -112,8 +112,7 @@ public class TestGetElement extends AbstractProcessor {
|
||||
Messager m = processingEnv.getMessager();
|
||||
int EXPECT = 1;
|
||||
if (nelems != EXPECT) {
|
||||
m.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Unexpected number of elements found: " + nelems + " expected: " + EXPECT);
|
||||
m.printError("Unexpected number of elements found: " + nelems + " expected: " + EXPECT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -177,13 +176,13 @@ public class TestGetElement extends AbstractProcessor {
|
||||
|
||||
Messager m = processingEnv.getMessager();
|
||||
if (e == null) {
|
||||
m.printMessage(Diagnostic.Kind.ERROR, "Null element found for " + text);
|
||||
m.printError("Null element found for " + text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (last && !e.getSimpleName().contentEquals("last")) {
|
||||
m.printMessage(Diagnostic.Kind.ERROR, "Unexpected name in last test: "
|
||||
+ e.getSimpleName() + ", expected: last");
|
||||
m.printError("Unexpected name in last test: "
|
||||
+ e.getSimpleName() + ", expected: last");
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, 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
|
||||
@ -36,7 +36,6 @@ import java.util.Set;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
import com.sun.source.tree.*;
|
||||
import com.sun.source.util.Trees;
|
||||
@ -328,7 +327,7 @@ public class TestOperators extends JavacTestingAbstractProcessor {
|
||||
testNode = returnNode.getExpression();
|
||||
}
|
||||
if (testNode.getKind() != kind) {
|
||||
log.printMessage(ERROR, testNode.getKind() + " != " + kind, e);
|
||||
log.printError(testNode.getKind() + " != " + kind, e);
|
||||
throw new AssertionError(testNode);
|
||||
}
|
||||
System.err.format("OK: %32s %s%n", kind, testNode);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -193,7 +193,7 @@ public class TestTrees extends AbstractProcessor {
|
||||
if (messager != null)
|
||||
// annotation processing will happen in a separate instance/classloader
|
||||
// so pass the message back to the calling instance.
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg);
|
||||
messager.printError(msg);
|
||||
else {
|
||||
System.err.println(msg);
|
||||
errors++;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -150,10 +150,9 @@ public class T7031108 extends JavacTestingAbstractProcessor {
|
||||
List<? extends Element> elems = p.getEnclosedElements();
|
||||
System.err.println("contents of package p: " + elems);
|
||||
if (elems.size() != 1 || !elems.get(0).getSimpleName().contentEquals("C")) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, PACKAGE_CONTENT_ERROR);
|
||||
messager.printError(PACKAGE_CONTENT_ERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, 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
|
||||
@ -98,7 +98,7 @@ public class DocCommentProcessor extends AbstractProcessor {
|
||||
DocTreeScanner<Void, Void> s = new DocTreeScanner<Void, Void>() {
|
||||
@Override
|
||||
public Void visitErroneous(ErroneousTree tree, Void ignore) {
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, tree.getDiagnostic().getMessage(null));
|
||||
messager.printNote(tree.getDiagnostic().getMessage(null));
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -31,8 +31,7 @@ import javax.tools.*;
|
||||
public class AnnoProc extends AbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
|
||||
if (renv.processingOver()) {
|
||||
Messager m = processingEnv.getMessager();
|
||||
m.printMessage(Diagnostic.Kind.ERROR, "Error!");
|
||||
processingEnv.getMessager().printError("Error!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -31,8 +31,7 @@ import javax.tools.*;
|
||||
public class AnnoProc extends AbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
|
||||
if (renv.processingOver()) {
|
||||
Messager m = processingEnv.getMessager();
|
||||
m.printMessage(Diagnostic.Kind.NOTE, "Note!");
|
||||
processingEnv.getMessager().printNote("Note!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -40,7 +40,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("class Gen { }");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -43,7 +43,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
FileObject fo2 = filer.createResource(
|
||||
StandardLocation.CLASS_OUTPUT, "", "HelloWorld.txt");
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -41,7 +41,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("Hello World!");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -44,7 +44,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("}\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -41,7 +41,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("class Gen { }");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -40,7 +40,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("class Gen { }");
|
||||
//out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -40,7 +40,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("class Gen { }");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -40,7 +40,7 @@ public class AnnoProc extends AbstractProcessor {
|
||||
out.write("class Gen { }");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -31,8 +31,7 @@ import javax.tools.*;
|
||||
public class AnnoProc extends AbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
|
||||
if (renv.processingOver()) {
|
||||
Messager m = processingEnv.getMessager();
|
||||
m.printMessage(Diagnostic.Kind.WARNING, "Warning!");
|
||||
processingEnv.getMessager().printWarning("Warning!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -38,7 +38,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
@interface TestMe {}
|
||||
|
||||
@ -56,7 +55,7 @@ public class T6424358 extends JavacTestingAbstractProcessor {
|
||||
System.err.println("Looking at " + e);
|
||||
if ("values".contentEquals(e.getSimpleName()) &&
|
||||
e.getModifiers().contains(Modifier.FINAL)) {
|
||||
log.printMessage(ERROR, "final modifier on values()", e);
|
||||
log.printError("final modifier on values()", e);
|
||||
throw new AssertionError("final modifier on values()"); // See bug 6403468
|
||||
}
|
||||
return null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -121,10 +121,9 @@ public class T7018098 extends JavacTestingAbstractProcessor {
|
||||
|
||||
<T> void checkEqual(String label, T actual, T expected) {
|
||||
if (actual != expected)
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Unexpected value for " + label
|
||||
+ "; expected: " + expected
|
||||
+ "; found: " + actual);
|
||||
messager.printError("Unexpected value for " + label
|
||||
+ "; expected: " + expected
|
||||
+ "; found: " + actual);
|
||||
}
|
||||
|
||||
int round = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -46,7 +46,6 @@ import javax.annotation.processing.SupportedOptions;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaCompiler.CompilationTask;
|
||||
import javax.tools.StandardLocation;
|
||||
@ -104,28 +103,28 @@ public class T7068437 {
|
||||
|
||||
boolean found;
|
||||
try {
|
||||
messager.printMessage(Kind.NOTE, "found previous content of length " +
|
||||
messager.printNote("found previous content of length " +
|
||||
filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length());
|
||||
found = true;
|
||||
} catch (FileNotFoundException | NoSuchFileException x) {
|
||||
messager.printMessage(Kind.NOTE, "not previously there");
|
||||
messager.printNote("not previously there");
|
||||
found = false;
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Kind.ERROR, "while reading: " + x);
|
||||
messager.printError("while reading: " + x);
|
||||
found = false;
|
||||
}
|
||||
|
||||
if (expectFile && !found) {
|
||||
messager.printMessage(Kind.ERROR, "expected file but file not found");
|
||||
messager.printError("expected file but file not found");
|
||||
}
|
||||
|
||||
try {
|
||||
Writer w = filer.createSourceFile("p.C").openWriter();
|
||||
w.write("/* hello! */ package p; class C {}");
|
||||
w.close();
|
||||
messager.printMessage(Kind.NOTE, "wrote new content");
|
||||
messager.printNote("wrote new content");
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Kind.ERROR, "while writing: " + x);
|
||||
messager.printError("while writing: " + x);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -47,7 +47,6 @@ import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaCompiler.CompilationTask;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
@ -145,11 +144,11 @@ public class T7068451 {
|
||||
System.err.println("running Proc");
|
||||
try {
|
||||
int len = filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length();
|
||||
messager.printMessage(Kind.NOTE, "C.java: found previous content of length " + len);
|
||||
messager.printNote("C.java: found previous content of length " + len);
|
||||
} catch (FileNotFoundException | NoSuchFileException x) {
|
||||
messager.printMessage(Kind.NOTE, "C.java: not previously there");
|
||||
messager.printNote("C.java: not previously there");
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Kind.ERROR, "while reading: " + x);
|
||||
messager.printError("while reading: " + x);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -157,9 +156,9 @@ public class T7068451 {
|
||||
Writer w = filer.createSourceFile("p.C").openWriter();
|
||||
w.write(body);
|
||||
w.close();
|
||||
messager.printMessage(Kind.NOTE, "C.java: wrote new content: " + body);
|
||||
messager.printNote("C.java: wrote new content: " + body);
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Kind.ERROR, "while writing: " + x);
|
||||
messager.printError("while writing: " + x);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -171,4 +170,3 @@ public class T7068451 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ public class AnnotationProcessing extends ModuleTestBase {
|
||||
|
||||
for (TypeElement clazz : ElementFilter.typesIn(roundEnv.getRootElements())) {
|
||||
for (VariableElement field : ElementFilter.fieldsIn(clazz.getEnclosedElements())) {
|
||||
messager.printMessage(Kind.NOTE, "field: " + field.getSimpleName());
|
||||
messager.printNote("field: " + field.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ public class AnnotationProcessing extends ModuleTestBase {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE, "AP Invoked");
|
||||
processingEnv.getMessager().printNote("AP Invoked");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ public class AnnotationProcessing extends ModuleTestBase {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE, "m1x/test.A AP Invoked");
|
||||
processingEnv.getMessager().printNote("m1x/test.A AP Invoked");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ public class AnnotationProcessing extends ModuleTestBase {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE, "m1x/test.B AP Invoked");
|
||||
processingEnv.getMessager().printNote("m1x/test.B AP Invoked");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2021, 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
|
||||
@ -86,8 +86,7 @@ public class PatternMatchPosTest extends AbstractProcessor {
|
||||
int start = (int) sp.getStartPosition(dataPath.getCompilationUnit(), tree);
|
||||
int end = (int) sp.getEndPosition(dataPath.getCompilationUnit(), tree);
|
||||
if (start != (-1) || end != (-1)) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
|
||||
text.substring(start, end));
|
||||
processingEnv.getMessager().printNote(text.substring(start, end));
|
||||
}
|
||||
}
|
||||
return super.scan(tree, p);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -26,7 +26,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -46,7 +45,7 @@ public class HelloWorldAP extends AbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv ) {
|
||||
boolean ret = true;
|
||||
if(!renv.processingOver() && !DONE) {
|
||||
msgr.printMessage(NOTE, "running process to create HelloWorld.");
|
||||
msgr.printNote("running process to create HelloWorld.");
|
||||
try {
|
||||
Writer pw = filer.createSourceFile("HelloWorld").openWriter();
|
||||
pw.write("public class HelloWorld {\n");
|
||||
@ -67,11 +66,11 @@ public class HelloWorldAP extends AbstractProcessor {
|
||||
DONE=true;
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
msgr.printMessage(ERROR, ioe.getMessage());
|
||||
msgr.printError(ioe.getMessage());
|
||||
ret = false;
|
||||
}
|
||||
catch (Exception e) {
|
||||
msgr.printMessage(ERROR, e.getMessage());
|
||||
msgr.printError(e.getMessage());
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -26,7 +26,6 @@ import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* Second of several processors to run.
|
||||
@ -35,7 +34,7 @@ public class ProcBar extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnvironment) {
|
||||
if (!roundEnvironment.processingOver())
|
||||
messager.printMessage(NOTE, "Hello from ProcBar");
|
||||
messager.printNote("Hello from ProcBar");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -26,7 +26,6 @@ import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* First of several processors to run.
|
||||
@ -35,7 +34,7 @@ public class ProcFoo extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnvironment) {
|
||||
if (!roundEnvironment.processingOver())
|
||||
messager.printMessage(NOTE, "Hello from ProcFoo");
|
||||
messager.printNote("Hello from ProcFoo");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
|
||||
public class T6365040 extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnvironment) {
|
||||
if (!roundEnvironment.processingOver())
|
||||
messager.printMessage(NOTE, "Hello from T6365040");
|
||||
messager.printNote("Hello from T6365040");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -32,7 +32,7 @@ public class A extends JavacTestingAbstractProcessor {
|
||||
Messager m = processingEnv.getMessager();
|
||||
for (TypeElement anno: annotations) {
|
||||
for (Element e: roundEnv.getElementsAnnotatedWith(anno))
|
||||
m.printMessage(Diagnostic.Kind.ERROR, "test", e);
|
||||
m.printError("test", e);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -26,7 +26,6 @@ import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.lang.model.util.ElementFilter.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
|
||||
@ -48,7 +47,7 @@ public class b6341534 extends JavacTestingAbstractProcessor {
|
||||
System.out.println("found " + e.toString() + " in dir1.");
|
||||
}
|
||||
catch(NullPointerException npe) {
|
||||
messager.printMessage(ERROR,npe.toString());
|
||||
messager.printError(npe.toString());
|
||||
//npe.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
@ -56,9 +55,9 @@ public class b6341534 extends JavacTestingAbstractProcessor {
|
||||
// on round 1, expect errorRaised == false && processingOver == false
|
||||
// on round 2, expect errorRaised == true && processingOver == true
|
||||
if( renv.errorRaised() != renv.processingOver()) {
|
||||
messager.printMessage(ERROR, "FAILED: round:" + r
|
||||
+ ", errorRaised:" + renv.errorRaised()
|
||||
+ ", processingOver:" + renv.processingOver());
|
||||
messager.printError("FAILED: round:" + r
|
||||
+ ", errorRaised:" + renv.errorRaised()
|
||||
+ ", processingOver:" + renv.processingOver());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -26,7 +26,6 @@ import java.util.*;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -122,7 +121,7 @@ public class ClassProcessor extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
|
||||
private void error(String msg) {
|
||||
messager.printMessage(Kind.ERROR, msg);
|
||||
messager.printError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -36,7 +36,7 @@ public class TestProcessor extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv) {
|
||||
if (++round == 1) {
|
||||
messager.printMessage(ERROR, "Deliberate Error");
|
||||
messager.printError("Deliberate Error");
|
||||
Trees trees = Trees.instance(processingEnv);
|
||||
TreePath elPath = trees.getPath(roundEnv.getRootElements().iterator().next());
|
||||
trees.printMessage(ERROR, "Deliberate Error on Trees",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, 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
|
||||
@ -38,7 +38,7 @@ import java.util.*;
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
|
||||
public class GenerateAndError extends JavacTestingAbstractProcessor {
|
||||
int round = 0;
|
||||
@ -50,7 +50,7 @@ public class GenerateAndError extends JavacTestingAbstractProcessor {
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
processingEnv.getMessager().printMessage(Kind.ERROR, "error");
|
||||
processingEnv.getMessager().printError("error");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, 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
|
||||
@ -41,14 +41,14 @@ import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
|
||||
public class StopAfterError extends JavacTestingAbstractProcessor {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
if (roundEnv.processingOver()) {
|
||||
processingEnv.getMessager().printMessage(Kind.ERROR, "Stop!");
|
||||
processingEnv.getMessager().printError("Stop!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -89,7 +89,7 @@ public class T6439826 extends AbstractProcessor {
|
||||
out.write("class Foo #"); // write a file that generates a scanner error
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
messager.printError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -453,7 +453,7 @@ public class T6920317 {
|
||||
/** Report an error to the annotation processing system. */
|
||||
void error(String msg) {
|
||||
Messager messager = processingEnv.getMessager();
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg);
|
||||
messager.printError(msg);
|
||||
}
|
||||
|
||||
int round;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -300,12 +300,10 @@ public class TestWarnErrorCount extends JavacTestingAbstractProcessor {
|
||||
ErrorKind ek = ErrorKind.valueOf(options.get("errKind"));
|
||||
WarnKind mwk = WarnKind.valueOf(options.get("msgrWarnKind"));
|
||||
WarnKind jwk = WarnKind.valueOf(options.get("javaWarnKind"));
|
||||
messager.printMessage(Diagnostic.Kind.NOTE,
|
||||
"Round " + round
|
||||
+ " " + roundEnv.getRootElements()
|
||||
+ ", last round: " + roundEnv.processingOver());
|
||||
messager.printMessage(Diagnostic.Kind.NOTE,
|
||||
"ek: " + ek + ", mwk: " + mwk + ", jwk: " + jwk);
|
||||
messager.printNote("Round " + round
|
||||
+ " " + roundEnv.getRootElements()
|
||||
+ ", last round: " + roundEnv.processingOver());
|
||||
messager.printNote("ek: " + ek + ", mwk: " + mwk + ", jwk: " + jwk);
|
||||
|
||||
if (round <= MAX_GEN && !roundEnv.processingOver())
|
||||
generate("Gen" + round,
|
||||
@ -313,10 +311,10 @@ public class TestWarnErrorCount extends JavacTestingAbstractProcessor {
|
||||
jwk.warn(round));
|
||||
|
||||
if (mwk.warn(round))
|
||||
messager.printMessage(Diagnostic.Kind.WARNING, "round " + round);
|
||||
messager.printWarning("round " + round);
|
||||
|
||||
if ((ek == ErrorKind.MESSAGER) && (round == ERROR_ROUND))
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "round " + round);
|
||||
messager.printError("round " + round);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -38,7 +38,6 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
import com.sun.source.util.Trees;
|
||||
import com.sun.tools.javac.api.JavacTrees;
|
||||
@ -76,12 +75,10 @@ public class TestContext extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
|
||||
<T> void check(T actual, T expected) {
|
||||
// messager.printMessage(NOTE, "expect: " + expected);
|
||||
// messager.printMessage(NOTE, "actual: " + actual);
|
||||
|
||||
if (actual != expected) {
|
||||
messager.printMessage(ERROR,
|
||||
"round " + round + " unexpected value for " + expected.getClass().getName() + ": " + actual);
|
||||
messager.printError("round " + round +
|
||||
" unexpected value for " + expected.getClass().getName() +
|
||||
": " + actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -41,7 +41,7 @@ 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");
|
||||
messager.printError("intentional error");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -56,8 +56,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
|
||||
/**
|
||||
* This processor raises errors or throws exceptions on different
|
||||
@ -83,12 +81,12 @@ public class TestReturnCode extends JavacTestingAbstractProcessor {
|
||||
exceptionOnFirst,
|
||||
exceptionOnLast);
|
||||
if (errorOnFirst)
|
||||
messager.printMessage(ERROR, "Error on first round.");
|
||||
messager.printError("Error on first round.");
|
||||
if (exceptionOnFirst)
|
||||
throw new RuntimeException("Exception on first round.");
|
||||
} else {
|
||||
if (errorOnLast)
|
||||
messager.printMessage(ERROR, "Error on last round.");
|
||||
messager.printError("Error on last round.");
|
||||
if (exceptionOnLast)
|
||||
throw new RuntimeException("Exception on last round.");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -236,7 +236,7 @@ public class TestSuppression {
|
||||
out.write(text);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
m.printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
m.printError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -36,7 +36,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.tools.*;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.JavaCompiler.CompilationTask;
|
||||
|
||||
public class TestGetResource2 {
|
||||
@ -128,14 +127,14 @@ public class TestGetResource2 {
|
||||
FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
|
||||
try {
|
||||
resource.openInputStream().close();
|
||||
messager.printMessage(Kind.NOTE, "found: " + resource.toUri());
|
||||
messager.printNote("found: " + resource.toUri());
|
||||
return true;
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri());
|
||||
messager.printError("could not read: " + resource.toUri());
|
||||
x.printStackTrace();
|
||||
}
|
||||
} catch (IOException x) {
|
||||
messager.printMessage(Kind.ERROR, "did not find resource");
|
||||
messager.printError("did not find resource");
|
||||
x.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -91,12 +91,11 @@ public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor {
|
||||
System.out.println("expected exception thrown: " + expected);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
|
||||
messager.printError("relative path: " + relative + ", kind: " + kind +
|
||||
", unexpected exception: " + e);
|
||||
return;
|
||||
}
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"relative path: " + relative + ", kind: " + kind + ", no exception thrown");
|
||||
messager.printError("relative path: " + relative + ", kind: " + kind + ", no exception thrown");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -86,8 +86,8 @@ public class TestValidRelativeNames extends JavacTestingAbstractProcessor {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
|
||||
messager.printError("relative path: " + relative + ", kind: " + kind +
|
||||
", unexpected exception: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public class TestValidRelativeNames extends JavacTestingAbstractProcessor {
|
||||
while ((n = reader.read(buf, 0, buf.length)) > 0)
|
||||
sb.append(new String(buf, 0, n));
|
||||
if (!sb.toString().equals(relative)) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "unexpected content: " + sb);
|
||||
messager.printError("unexpected content: " + sb);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -119,14 +119,14 @@ public class TestValidRelativeNames extends JavacTestingAbstractProcessor {
|
||||
while ((n = in.read(buf, 0, buf.length)) > 0)
|
||||
sb.append(new String(buf, 0, n));
|
||||
if (!sb.toString().equals(relative)) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "unexpected content: " + sb);
|
||||
messager.printError("unexpected content: " + sb);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
|
||||
messager.printError("relative path: " + relative + ", kind: " + kind +
|
||||
", unexpected exception: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -122,7 +122,7 @@ public class TestClose2 extends AbstractProcessor implements TaskListener {
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
Messager messager = processingEnv.getMessager();
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, "processing");
|
||||
messager.printNote("processing");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, 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
|
||||
@ -50,7 +50,6 @@ import javax.tools.JavaFileObject;
|
||||
import javax.tools.SimpleJavaFileObject;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
import static javax.tools.JavaFileObject.Kind.*;
|
||||
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||
@ -72,9 +71,9 @@ public class MessagerDiags extends AbstractProcessor {
|
||||
RoundEnvironment roundEnv) {
|
||||
Messager messager = processingEnv.getMessager();
|
||||
for (Element e : roundEnv.getRootElements()) {
|
||||
messager.printMessage(WARNING, WRN_NO_SOURCE);
|
||||
messager.printMessage(WARNING, WRN_WITH_SOURCE, e);
|
||||
messager.printMessage(WARNING, WRN_NO_SOURCE);
|
||||
messager.printWarning(WRN_NO_SOURCE);
|
||||
messager.printWarning(WRN_WITH_SOURCE, e);
|
||||
messager.printWarning(WRN_NO_SOURCE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -42,16 +42,14 @@ import javax.lang.model.util.*;
|
||||
import static javax.lang.model.util.ElementFilter.*;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
public class T6341534 extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
|
||||
messager.printMessage(NOTE,
|
||||
String.valueOf(eltUtils.getPackageElement("no.such.package")));
|
||||
messager.printNote(String.valueOf(eltUtils.getPackageElement("no.such.package")));
|
||||
PackageElement dir = eltUtils.getPackageElement("dir");
|
||||
messager.printMessage(NOTE, dir.getQualifiedName().toString());
|
||||
messager.printNote(dir.getQualifiedName().toString());
|
||||
for (Element e : dir.getEnclosedElements())
|
||||
messager.printMessage(NOTE, e.toString());
|
||||
messager.printNote(e.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2021, 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
|
||||
@ -42,25 +42,14 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.RecordComponentElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.util.ElementScanner14;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.*;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -185,22 +174,20 @@ public class CheckingAccessorsOnLoadedRecordClasses extends TestRunner {
|
||||
|
||||
if (recordComponents.isEmpty()) {
|
||||
processingEnv.getMessager()
|
||||
.printMessage(Diagnostic.Kind.ERROR, "Record element " + recordElement.getQualifiedName()
|
||||
+ " has no record components");
|
||||
.printError("Record element " + recordElement.getQualifiedName()
|
||||
+ " has no record components");
|
||||
} else {
|
||||
for (RecordComponentElement recordComponent : recordComponents) {
|
||||
ExecutableElement accessor = recordComponent.getAccessor();
|
||||
if (accessor == null) {
|
||||
processingEnv.getMessager()
|
||||
.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Record component " + recordComponent.getSimpleName() + " from record " + recordElement
|
||||
.getQualifiedName() + " has no accessor");
|
||||
.printError("Record component " + recordComponent.getSimpleName() + " from record " + recordElement
|
||||
.getQualifiedName() + " has no accessor");
|
||||
}
|
||||
if (!accessor.getSimpleName().equals(recordComponent.getSimpleName())) {
|
||||
processingEnv.getMessager()
|
||||
.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Record component " + recordComponent.getSimpleName() + " from record " +
|
||||
recordElement.getQualifiedName() + " has an accessor with name " + accessor.getSimpleName());
|
||||
.printError("Record component " + recordComponent.getSimpleName() + " from record " +
|
||||
recordElement.getQualifiedName() + " has an accessor with name " + accessor.getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, 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
|
||||
@ -39,27 +39,17 @@ import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.RecordComponentElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.util.ElementScanner14;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.*;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.util.ElementScanner14;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -290,7 +280,7 @@ public class CheckingTypeAnnotationsOnRecords extends TestRunner {
|
||||
}
|
||||
|
||||
private void error(String text) {
|
||||
processingEnv.getMessager().printMessage(Kind.ERROR, text);
|
||||
processingEnv.getMessager().printError(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2021, 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
|
||||
@ -49,7 +49,6 @@ import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.util.ElementScanner14;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.*;
|
||||
|
||||
import toolbox.JavacTask;
|
||||
@ -136,10 +135,10 @@ public class JavaxLangModelForRecords extends TestRunner {
|
||||
|
||||
for (TypeElement clazz : ElementFilter.typesIn(roundEnv.getRootElements())) {
|
||||
for (VariableElement field : ElementFilter.fieldsIn(clazz.getEnclosedElements())) {
|
||||
messager.printMessage(Kind.NOTE, "field: " + field.getSimpleName());
|
||||
messager.printNote("field: " + field.getSimpleName());
|
||||
}
|
||||
for (RecordComponentElement rc : ElementFilter.recordComponentsIn(clazz.getEnclosedElements())) {
|
||||
messager.printMessage(Kind.NOTE, "record component: " + rc.getSimpleName());
|
||||
messager.printNote("record component: " + rc.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -30,7 +30,6 @@ import javax.lang.model.util.*;
|
||||
import java.util.*;
|
||||
import com.sun.source.tree.*;
|
||||
import com.sun.source.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* Using the tree API, retrieve element representations of anonymous
|
||||
@ -65,9 +64,8 @@ public class TestAnonSourceNames extends JavacTestingAbstractProcessor {
|
||||
public Void visitClass(ClassTree node, CompilationUnitTree cu) {
|
||||
Element element = trees.getElement(trees.getPath(cu, node));
|
||||
if (element == null) {
|
||||
processingEnv.getMessager().printMessage(ERROR,
|
||||
"No element retrieved for node named ''" +
|
||||
node.getSimpleName() + "''.");
|
||||
processingEnv.getMessager().printError("No element retrieved for node named ''" +
|
||||
node.getSimpleName() + "''.");
|
||||
} else {
|
||||
|
||||
System.out.println("\nVisiting class ``" + element.getSimpleName() +
|
||||
|
@ -41,7 +41,6 @@ import java.util.regex.*;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import static javax.lang.model.util.ElementFilter.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* Test some basic workings of javax.lang.element.ExecutableElement
|
||||
@ -62,12 +61,12 @@ public class TestExecutableElement extends JavacTestingAbstractProcessor impleme
|
||||
} else {
|
||||
String expectedMethodCountStr = processingEnv.getOptions().get("expectedMethodCount");
|
||||
if (expectedMethodCountStr == null) {
|
||||
messager.printMessage(ERROR, "No expected method count specified.");
|
||||
messager.printError("No expected method count specified.");
|
||||
} else {
|
||||
int expectedMethodCount = Integer.parseInt(expectedMethodCountStr);
|
||||
|
||||
if (seenMethods != expectedMethodCount) {
|
||||
messager.printMessage(ERROR, "Wrong number of seen methods: " + seenMethods);
|
||||
messager.printError("Wrong number of seen methods: " + seenMethods);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,9 +86,8 @@ public class TestExecutableElement extends JavacTestingAbstractProcessor impleme
|
||||
|
||||
if (expectedDefault) {
|
||||
if (!method.getModifiers().contains(Modifier.DEFAULT)) {
|
||||
messager.printMessage(ERROR,
|
||||
"Modifier \"default\" not present as expected.",
|
||||
method);
|
||||
messager.printError("Modifier \"default\" not present as expected.",
|
||||
method);
|
||||
}
|
||||
|
||||
// Check printing output
|
||||
@ -98,29 +96,26 @@ public class TestExecutableElement extends JavacTestingAbstractProcessor impleme
|
||||
Pattern p = Pattern.compile(expectedIsDefault.expectedTextRegex(), Pattern.DOTALL);
|
||||
|
||||
if (! p.matcher(stringWriter.toString()).matches()) {
|
||||
messager.printMessage(ERROR,
|
||||
new Formatter().format("Unexpected printing ouptput:%n\tgot %s,%n\texpected pattern %s.",
|
||||
stringWriter.toString(),
|
||||
expectedIsDefault.expectedTextRegex()).toString(),
|
||||
method);
|
||||
messager.printError(new Formatter().format("Unexpected printing ouptput:%n\tgot %s,%n\texpected pattern %s.",
|
||||
stringWriter.toString(),
|
||||
expectedIsDefault.expectedTextRegex()).toString(),
|
||||
method);
|
||||
}
|
||||
|
||||
System.out.println("\t" + stringWriter.toString());
|
||||
|
||||
} else {
|
||||
if (method.getModifiers().contains(Modifier.DEFAULT)) {
|
||||
messager.printMessage(ERROR,
|
||||
"Modifier \"default\" present when not expected.",
|
||||
method);
|
||||
messager.printError("Modifier \"default\" present when not expected.",
|
||||
method);
|
||||
}
|
||||
}
|
||||
|
||||
if (methodIsDefault != expectedDefault) {
|
||||
messager.printMessage(ERROR,
|
||||
new Formatter().format("Unexpected Executable.isDefault result: got ``%s'', expected ``%s''.",
|
||||
expectedDefault,
|
||||
methodIsDefault).toString(),
|
||||
method);
|
||||
messager.printError(new Formatter().format("Unexpected Executable.isDefault result: got ``%s'', expected ``%s''.",
|
||||
expectedDefault,
|
||||
methodIsDefault).toString(),
|
||||
method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* Verify that proper type objects are returned from ExecutableElement.getReceiverType
|
||||
@ -50,7 +49,7 @@ public class TestExecutableReceiverType extends JavacTestingAbstractProcessor {
|
||||
count += testType(elements.getTypeElement("MethodHost.Nested"));
|
||||
|
||||
if (count == 0) {
|
||||
messager.printMessage(ERROR, "No executables visited.");
|
||||
messager.printError("No executables visited.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -75,10 +74,9 @@ public class TestExecutableReceiverType extends JavacTestingAbstractProcessor {
|
||||
TypeKind actualKind = executable.getReceiverType().getKind();
|
||||
|
||||
if (actualKind != expectedKind) {
|
||||
messager.printMessage(ERROR,
|
||||
String.format("Unexpected TypeKind on receiver of %s:" +
|
||||
" expected %s\t got %s%n",
|
||||
executable, expectedKind, actualKind));
|
||||
messager.printError(String.format("Unexpected TypeKind on receiver of %s:" +
|
||||
" expected %s\t got %s%n",
|
||||
executable, expectedKind, actualKind));
|
||||
}
|
||||
|
||||
// Get kind from the type of the executable directly
|
||||
@ -90,10 +88,9 @@ public class TestExecutableReceiverType extends JavacTestingAbstractProcessor {
|
||||
}.visit(executable.asType());
|
||||
|
||||
if (kindFromType != expectedKind) {
|
||||
messager.printMessage(ERROR,
|
||||
String.format("Unexpected TypeKind on executable's asType() of %s:" +
|
||||
" expected %s\t got %s%n",
|
||||
executable, expectedKind, kindFromType));
|
||||
messager.printError(String.format("Unexpected TypeKind on executable's asType() of %s:" +
|
||||
" expected %s\t got %s%n",
|
||||
executable, expectedKind, kindFromType));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -38,7 +38,7 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
|
||||
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
@ -101,7 +101,7 @@ public class TestMissingElement extends JavacTestingAbstractProcessor {
|
||||
out.println("unexpected " + label + ": " + te + "\n"
|
||||
+ " found: " + found + "\n"
|
||||
+ "expect: " + expect);
|
||||
messager.printMessage(ERROR, "unexpected " + label + " found: " + found + "; expected: " + expect, te);
|
||||
messager.printError("unexpected " + label + " found: " + found + "; expected: " + expect, te);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -87,7 +87,7 @@ public class Generator extends JavacTestingAbstractProcessor {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "problem writing file: " + ex);
|
||||
messager.printError("problem writing file: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,6 @@ import javax.lang.model.type.*;
|
||||
import javax.lang.model.util.*;
|
||||
import java.time.*;
|
||||
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import toolbox.JavacTask;
|
||||
import toolbox.Task;
|
||||
import toolbox.Task.Mode;
|
||||
@ -185,11 +183,11 @@ public class TestSealed extends TestRunner {
|
||||
|
||||
@Override
|
||||
public Void visitType(TypeElement element, Void p) {
|
||||
messager.printMessage(Kind.NOTE, "visiting: " + element.getSimpleName() + " Modifiers: " + element.getModifiers());
|
||||
messager.printNote("visiting: " + element.getSimpleName() + " Modifiers: " + element.getModifiers());
|
||||
List<? extends TypeMirror> permittedSubclasses = element.getPermittedSubclasses();
|
||||
messager.printMessage(Kind.NOTE, String.format(" this class has: %d, permitted subclasses", permittedSubclasses.size()));
|
||||
messager.printNote(String.format(" this class has: %d, permitted subclasses", permittedSubclasses.size()));
|
||||
for (TypeMirror tm: permittedSubclasses) {
|
||||
messager.printMessage(Kind.NOTE, String.format(" permitted subclass: %s", ((DeclaredType)tm).asElement().getSimpleName()));
|
||||
messager.printNote(String.format(" permitted subclass: %s", ((DeclaredType)tm).asElement().getSimpleName()));
|
||||
}
|
||||
return super.visitType(element, p);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -36,7 +36,6 @@
|
||||
import java.util.Set;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* Verify that TypeElement for interfaces does not have Modifier.DEFAULT in getModifiers().
|
||||
@ -48,7 +47,7 @@ public class TestTypeElement extends JavacTestingAbstractProcessor {
|
||||
for (Element element : roundEnv.getRootElements()) {
|
||||
if (element.getKind().isClass() || element.getKind().isInterface()) {
|
||||
if (element.getModifiers().contains(Modifier.DEFAULT))
|
||||
messager.printMessage(ERROR, "Modifier.DEFAULT not expected on classes/interfaces");
|
||||
messager.printError("Modifier.DEFAULT not expected on classes/interfaces");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -103,19 +103,19 @@ public class TestTypeParameter<T> extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
|
||||
void note(String msg) {
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, msg);
|
||||
messager.printNote(msg);
|
||||
}
|
||||
|
||||
void note(String msg, Element e) {
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
|
||||
messager.printNote(msg, e);
|
||||
}
|
||||
|
||||
void error(String msg, Element e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
|
||||
messager.printError(msg, e);
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg);
|
||||
messager.printError(msg);
|
||||
}
|
||||
|
||||
// additional generic elements to test
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -148,19 +148,19 @@ public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2
|
||||
}
|
||||
|
||||
void note(String msg) {
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, msg);
|
||||
messager.printNote(msg);
|
||||
}
|
||||
|
||||
void note(String msg, Element e) {
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
|
||||
messager.printNote(msg, e);
|
||||
}
|
||||
|
||||
void error(String msg, Element e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
|
||||
messager.printError(msg, e);
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg);
|
||||
messager.printError(msg);
|
||||
}
|
||||
|
||||
Class<? extends Annotation>[] ALL_ANNOTATIONS = new Class[] {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -43,7 +43,6 @@ import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
@ -65,7 +64,7 @@ public class TestDeprecation extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
|
||||
if (failure)
|
||||
processingEnv.getMessager().printMessage(ERROR, "Deprecation mismatch found!");
|
||||
processingEnv.getMessager().printError("Deprecation mismatch found!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -40,7 +40,6 @@ import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.lang.model.util.ElementFilter.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
import static javax.tools.StandardLocation.*;
|
||||
import java.io.*;
|
||||
|
||||
@ -57,14 +56,13 @@ public class TestIsFunctionalInterface extends JavacTestingAbstractProcessor {
|
||||
System.out.println(type);
|
||||
if (elements.isFunctionalInterface(type) !=
|
||||
type.getAnnotation(ExpectedIsFunInt.class).value()) {
|
||||
messager.printMessage(ERROR,
|
||||
"Mismatch between expected and computed isFunctionalInterface",
|
||||
type);
|
||||
messager.printError("Mismatch between expected and computed isFunctionalInterface",
|
||||
type);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (count <= 0)
|
||||
messager.printMessage(ERROR, "No types with ExpectedIsFunInt processed.");
|
||||
messager.printError("No types with ExpectedIsFunInt processed.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -255,10 +255,9 @@ public class TestDocComments extends JavacTestingAbstractProcessor {
|
||||
return;
|
||||
|
||||
if (dc == null)
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e);
|
||||
messager.printError("doc comment is null", e);
|
||||
else {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"unexpected comment: \"" + dc + "\", expected \"" + expect + "\"", e);
|
||||
messager.printError("unexpected comment: \"" + dc + "\", expected \"" + expect + "\"", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, 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
|
||||
@ -82,7 +82,7 @@ public class TestPackageInfoComments extends JavacTestingAbstractProcessor {
|
||||
@Override
|
||||
public Void visitPackage(PackageElement e, Void v) {
|
||||
if (elements.getDocComment(e) == null)
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e);
|
||||
messager.printError("doc comment is null", e);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -101,7 +101,7 @@ public class Test extends JavacTestingAbstractProcessor {
|
||||
RoundEnvironment roundEnv) {
|
||||
if (!roundEnv.processingOver()) {
|
||||
for (TypeElement typeElt : ElementFilter.typesIn(roundEnv.getRootElements())) {
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, "processing " + typeElt);
|
||||
messager.printNote("processing " + typeElt);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -47,11 +47,11 @@ public class Test extends JavacTestingAbstractProcessor {
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
round++;
|
||||
messager.printMessage(Diagnostic.Kind.NOTE, "round " + round);
|
||||
messager.printNote("round " + round);
|
||||
if (round <= MAX_ROUNDS)
|
||||
generateSource("Gen" + round);
|
||||
if (roundEnv.processingOver())
|
||||
messager.printMessage(Diagnostic.Kind.WARNING, "last round");
|
||||
messager.printWarning("last round");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, 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
|
||||
@ -93,7 +93,7 @@ public class BaseClassesNotReRead extends AbstractProcessor {
|
||||
out.write(code);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
processingEnv.getMessager().printError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, 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
|
||||
@ -57,7 +57,7 @@ public class ClassDependingOnGenerated extends JavacTestingAbstractProcessor {
|
||||
out.write(code);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
processingEnv.getMessager().printError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, Red Hat, Inc.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -149,7 +149,7 @@ public class ErrClassSymbolTypeFixed extends TestRunner {
|
||||
out.write(B_JAVA);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "problem writing file: " + e);
|
||||
messager.printError("problem writing file: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ public class GenerateAnonymousClass extends JavacTestingAbstractProcessor {
|
||||
try (OutputStream out = filer.createClassFile("T").openOutputStream()) {
|
||||
out.write(mfm.getFileBytes(StandardLocation.CLASS_OUTPUT, "T"));
|
||||
} catch (IOException e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
processingEnv.getMessager().printError(e.toString());
|
||||
}
|
||||
try (OutputStream out = filer.createClassFile("T$1").openOutputStream()) {
|
||||
out.write(mfm.getFileBytes(StandardLocation.CLASS_OUTPUT, "T$1"));
|
||||
} catch (IOException e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
processingEnv.getMessager().printError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, 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
|
||||
@ -90,7 +90,7 @@ public class OverwriteBetweenCompilations extends JavacTestingAbstractProcessor
|
||||
code = code.replace("NAME", "GeneratedSource");
|
||||
out.write(code);
|
||||
} catch (IOException e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
processingEnv.getMessager().printError(e.toString());
|
||||
}
|
||||
try (OutputStream out = filer.createClassFile("GeneratedClass").openOutputStream()) {
|
||||
String code = pass != 2 ? GENERATED_INIT : GENERATED_UPDATE;
|
||||
@ -106,7 +106,7 @@ public class OverwriteBetweenCompilations extends JavacTestingAbstractProcessor
|
||||
|
||||
out.write(mfm.getFileBytes(StandardLocation.CLASS_OUTPUT, "GeneratedClass"));
|
||||
} catch (IOException e) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
|
||||
processingEnv.getMessager().printError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2021, 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
|
||||
@ -45,7 +45,7 @@ import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
|
||||
/**
|
||||
* This processor returns the supported source level as indicated by
|
||||
@ -61,8 +61,7 @@ public class TestSourceVersionWarnings extends AbstractProcessor {
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
String sourceVersion = processingEnv.getOptions().get("SourceVersion");
|
||||
if (sourceVersion == null) {
|
||||
processingEnv.getMessager().printMessage(WARNING,
|
||||
"No SourceVersion option given");
|
||||
processingEnv.getMessager().printWarning("No SourceVersion option given");
|
||||
return SourceVersion.RELEASE_8;
|
||||
} else {
|
||||
return SourceVersion.valueOf(sourceVersion);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -38,7 +38,6 @@
|
||||
import java.util.*;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.element.*;
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
@SupportedOptions("error")
|
||||
public class TestProcUseImplicitWarning extends JavacTestingAbstractProcessor {
|
||||
@ -52,7 +51,7 @@ public class TestProcUseImplicitWarning extends JavacTestingAbstractProcessor {
|
||||
if (round == 1) {
|
||||
boolean error = options.containsKey("error");
|
||||
if (error)
|
||||
messager.printMessage(ERROR, "error generated per option");
|
||||
messager.printError("error generated per option");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -45,7 +45,7 @@ public class WError1 extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv) {
|
||||
if (++round == 1) {
|
||||
messager.printMessage(Diagnostic.Kind.WARNING, "round 1");
|
||||
messager.printWarning("round 1");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -45,7 +45,7 @@ public class WErrorLast extends JavacTestingAbstractProcessor {
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv) {
|
||||
if (roundEnv.processingOver()) {
|
||||
messager.printMessage(Diagnostic.Kind.WARNING, "last round");
|
||||
messager.printWarning("last round");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, 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
|
||||
@ -44,7 +44,7 @@ import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
|
||||
import com.sun.tools.javac.code.Symbol.VarSymbol;
|
||||
|
||||
@ -67,7 +67,7 @@ public class ArrayTypeToString extends JavacTestingAbstractProcessor {
|
||||
s = s.replaceAll("\\s", "");
|
||||
|
||||
// Expected: "@Foo(0)java.lang.String@Foo(3)[]@Foo(2)[]@Foo(1)[]"
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE, s);
|
||||
processingEnv.getMessager().printNote(s);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -53,7 +53,6 @@ import javax.lang.model.type.IntersectionType;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.type.TypeVariable;
|
||||
import javax.lang.model.type.WildcardType;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
public class NoPrivateTypesExported extends JavacTestingAbstractProcessor {
|
||||
|
||||
@ -310,10 +309,10 @@ public class NoPrivateTypesExported extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
|
||||
private void error(String text) {
|
||||
processingEnv.getMessager().printMessage(Kind.ERROR, text);
|
||||
processingEnv.getMessager().printError(text);
|
||||
}
|
||||
|
||||
private void note(String text) {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE, text);
|
||||
processingEnv.getMessager().printNote(text);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -99,8 +99,7 @@ public class TreePosRoundsTest extends AbstractProcessor {
|
||||
TreePath p = trees.getPath(e);
|
||||
new TestTreeScanner(p.getCompilationUnit(), trees).scan(trees.getPath(e), null);
|
||||
} catch (IOException ex) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Cannot get source: " + ex, e);
|
||||
messager.printError("Cannot get source: " + ex, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,13 +164,13 @@ public class TreePosRoundsTest extends AbstractProcessor {
|
||||
|
||||
int start = (int)sourcePositions.getStartPosition(unit, tree);
|
||||
if (start == Diagnostic.NOPOS) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "start pos not set for " + trim(tree));
|
||||
messager.printError("start pos not set for " + trim(tree));
|
||||
return;
|
||||
}
|
||||
|
||||
int end = (int)sourcePositions.getEndPosition(unit, tree);
|
||||
if (end == Diagnostic.NOPOS) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, "end pos not set for " + trim(tree));
|
||||
messager.printError("end pos not set for " + trim(tree));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -190,8 +189,8 @@ public class TreePosRoundsTest extends AbstractProcessor {
|
||||
}
|
||||
|
||||
if (!equal) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"unexpected value found: '" + found + "'; expected: '" + expect + "'");
|
||||
messager.printError("unexpected value found: '" + found +
|
||||
"'; expected: '" + expect + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, 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
|
||||
@ -101,7 +101,7 @@ public class TestProcessor extends AbstractProcessor {
|
||||
/** Report an error to the annotation processing system. */
|
||||
void error(String msg) {
|
||||
Messager messager = processingEnv.getMessager();
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, msg);
|
||||
messager.printError(msg);
|
||||
}
|
||||
|
||||
/** Report an error to the annotation processing system. */
|
||||
@ -109,7 +109,7 @@ public class TestProcessor extends AbstractProcessor {
|
||||
// need better API for reporting tree position errors to the messager
|
||||
Messager messager = processingEnv.getMessager();
|
||||
String text = file.getName() + ":" + getLine(file, tree) + ": " + msg;
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, text);
|
||||
messager.printError(text);
|
||||
}
|
||||
|
||||
/** Get the line number for the primary position for a tree.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, 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
|
||||
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import java.util.Set;
|
||||
|
||||
@ -42,7 +41,7 @@ public class NewlineOnlyDiagnostic extends JavacTestingAbstractProcessor {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> types,RoundEnvironment rEnv) {
|
||||
processingEnv.getMessager().printMessage(Kind.NOTE,"\n");
|
||||
processingEnv.getMessager().printNote("\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, 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
|
||||
@ -115,10 +115,9 @@ public class T6597678 extends JavacTestingAbstractProcessor {
|
||||
|
||||
<T> void checkEqual(String label, T actual, T expected) {
|
||||
if (actual != expected)
|
||||
messager.printMessage(Diagnostic.Kind.ERROR,
|
||||
"Unexpected value for " + label
|
||||
+ "; expected: " + expected
|
||||
+ "; found: " + actual);
|
||||
messager.printError("Unexpected value for " + label
|
||||
+ "; expected: " + expected
|
||||
+ "; found: " + actual);
|
||||
}
|
||||
|
||||
int round = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user