test/tools/javac/processing/messager/MessagerBasics.java

changeset 699
d2aaaec153e8
parent 554
9d9f26857129
child 1466
b52a38d4536c
equal deleted inserted replaced
698:f94af0667151 699:d2aaaec153e8
1 /* 1 /*
2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
24 /* 24 /*
25 * @test 25 * @test
26 * @bug 6341173 6341072 26 * @bug 6341173 6341072
27 * @summary Test presence of Messager methods 27 * @summary Test presence of Messager methods
28 * @author Joseph D. Darcy 28 * @author Joseph D. Darcy
29 * @library ../../lib
30 * @build JavacTestingAbstractProcessor
29 * @compile MessagerBasics.java 31 * @compile MessagerBasics.java
30 * @compile -processor MessagerBasics -proc:only MessagerBasics.java 32 * @compile -processor MessagerBasics -proc:only MessagerBasics.java
31 * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java 33 * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
32 * @compile -processor MessagerBasics MessagerBasics.java 34 * @compile -processor MessagerBasics MessagerBasics.java
33 * @compile/fail -processor MessagerBasics -AfinalError MessagerBasics.java 35 * @compile/fail -processor MessagerBasics -AfinalError MessagerBasics.java
37 import javax.annotation.processing.*; 39 import javax.annotation.processing.*;
38 import javax.lang.model.element.*; 40 import javax.lang.model.element.*;
39 import javax.lang.model.util.*; 41 import javax.lang.model.util.*;
40 import static javax.tools.Diagnostic.Kind.*; 42 import static javax.tools.Diagnostic.Kind.*;
41 43
42 @SupportedAnnotationTypes("*")
43 @SupportedOptions("finalError") 44 @SupportedOptions("finalError")
44 public class MessagerBasics extends AbstractProcessor { 45 public class MessagerBasics extends JavacTestingAbstractProcessor {
45 public boolean process(Set<? extends TypeElement> annotations, 46 public boolean process(Set<? extends TypeElement> annotations,
46 RoundEnvironment roundEnv) { 47 RoundEnvironment roundEnv) {
47 Messager m = processingEnv.getMessager();
48 if (roundEnv.processingOver()) { 48 if (roundEnv.processingOver()) {
49 if (processingEnv.getOptions().containsKey("finalError")) 49 if (processingEnv.getOptions().containsKey("finalError"))
50 m.printMessage(ERROR, "Does not compute"); 50 messager.printMessage(ERROR, "Does not compute");
51 else { 51 else {
52 m.printMessage(NOTE, "Post no bills"); 52 messager.printMessage(NOTE, "Post no bills");
53 m.printMessage(WARNING, "Beware the ides of March!"); 53 messager.printMessage(WARNING, "Beware the ides of March!");
54 } 54 }
55 } 55 }
56 return true; 56 return true;
57 } 57 }
58 } 58 }

mercurial