MessagerBasics.java revision 1465:b52a38d4536c
121259Swollman/*
221259Swollman * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
321259Swollman * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
421259Swollman *
521259Swollman * This code is free software; you can redistribute it and/or modify it
621259Swollman * under the terms of the GNU General Public License version 2 only, as
721259Swollman * published by the Free Software Foundation.
821259Swollman *
921259Swollman * This code is distributed in the hope that it will be useful, but WITHOUT
1021259Swollman * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1121259Swollman * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1221259Swollman * version 2 for more details (a copy is included in the LICENSE file that
1321259Swollman * accompanied this code).
1421259Swollman *
1521259Swollman * You should have received a copy of the GNU General Public License version
1621259Swollman * 2 along with this work; if not, write to the Free Software Foundation,
1721259Swollman * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1821259Swollman *
1921259Swollman * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2021259Swollman * or visit www.oracle.com if you need additional information or have any
2121259Swollman * questions.
2221259Swollman */
2321259Swollman
2421259Swollman/*
2521259Swollman * @test
2621259Swollman * @bug     6341173 6341072
2721259Swollman * @summary Test presence of Messager methods
2821259Swollman * @author  Joseph D. Darcy
2921259Swollman * @library /tools/javac/lib
3021259Swollman * @build   JavacTestingAbstractProcessor
3121259Swollman * @compile MessagerBasics.java
3221259Swollman * @compile -processor MessagerBasics -proc:only MessagerBasics.java
3321259Swollman * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
3450477Speter * @compile -processor MessagerBasics MessagerBasics.java
3521259Swollman * @compile/fail -processor MessagerBasics -AfinalError MessagerBasics.java
3621259Swollman */
3721259Swollman
3821259Swollmanimport java.util.Set;
3921259Swollmanimport javax.annotation.processing.*;
4021259Swollmanimport javax.lang.model.element.*;
4121259Swollmanimport javax.lang.model.util.*;
4221259Swollmanimport static javax.tools.Diagnostic.Kind.*;
4321259Swollman
4421259Swollman@SupportedOptions("finalError")
4521259Swollmanpublic class MessagerBasics extends JavacTestingAbstractProcessor {
4621259Swollman    public boolean process(Set<? extends TypeElement> annotations,
4721259Swollman                           RoundEnvironment roundEnv) {
4821259Swollman        if (roundEnv.processingOver()) {
4921259Swollman            if (processingEnv.getOptions().containsKey("finalError"))
5021259Swollman                messager.printMessage(ERROR,   "Does not compute");
5121259Swollman            else {
5221259Swollman                messager.printMessage(NOTE,    "Post no bills");
5321259Swollman                messager.printMessage(WARNING, "Beware the ides of March!");
5421259Swollman            }
5521259Swollman        }
5621259Swollman        return true;
5721259Swollman    }
5821259Swollman}
5921259Swollman