langtools/test/tools/javac/processing/messager/MessagerBasics.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 28335 0b37a4232e35
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine

/*
 * @test    /nodynamiccopyright/
 * @bug     6341173 6341072
 * @summary Test presence of Messager methods
 * @author  Joseph D. Darcy
 * @library /tools/javac/lib
 * @modules java.compiler
 *          jdk.compiler
 * @build   JavacTestingAbstractProcessor
 * @compile MessagerBasics.java
 * @compile -processor MessagerBasics -proc:only MessagerBasics.java
 * @compile/fail/ref=MessagerBasics.out -XDrawDiagnostics -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
 * @compile -processor MessagerBasics MessagerBasics.java
 * @compile/fail/ref=MessagerBasics.out -XDrawDiagnostics -processor MessagerBasics -AfinalError MessagerBasics.java
 */

import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.lang.model.util.*;
import static javax.tools.Diagnostic.Kind.*;

@SupportedOptions("finalError")
public class MessagerBasics extends JavacTestingAbstractProcessor {
    public boolean process(Set<? extends TypeElement> annotations,
                           RoundEnvironment roundEnv) {
        if (roundEnv.processingOver()) {
            if (processingEnv.getOptions().containsKey("finalError"))
                messager.printMessage(ERROR,   "Does not compute");
            else {
                messager.printMessage(NOTE,    "Post no bills");
                messager.printMessage(WARNING, "Beware the ides of March!");
            }
        }
        return true;
    }
}