Thu, 15 Dec 2011 15:47:47 -0800
Added tag jdk8-b16 for changeset ec2c0973cc31
1 /*
2 * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
25 import com.sun.mirror.apt.*;
26 import com.sun.mirror.declaration.*;
27 import com.sun.mirror.type.*;
28 import com.sun.mirror.util.*;
30 import java.util.Collection;
31 import java.util.Set;
32 import java.util.Arrays;
35 import static java.util.Collections.*;
36 import static com.sun.mirror.util.DeclarationVisitors.*;
38 /*
39 * Construct a processor that does nothing but report an error.
40 */
41 public class ErrorAPF implements AnnotationProcessorFactory {
42 static class ErrorAP implements AnnotationProcessor {
43 AnnotationProcessorEnvironment env;
44 ErrorAP(AnnotationProcessorEnvironment env) {
45 this.env = env;
46 }
48 public void process() {
49 Messager messager = env.getMessager();
50 messager.printError("It's a mad, mad, mad, mad world");
51 messager.printError("Something wicked this way comes");
53 for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations())
54 messager.printError(typeDecl.getPosition(), "Boring class name");
55 }
56 }
58 static Collection<String> supportedTypes;
59 static {
60 String types[] = {"*"};
61 supportedTypes = unmodifiableCollection(Arrays.asList(types));
62 }
64 static Collection<String> supportedOptions;
65 static {
66 String options[] = {""};
67 supportedOptions = unmodifiableCollection(Arrays.asList(options));
68 }
70 public Collection<String> supportedOptions() {
71 return supportedOptions;
72 }
74 public Collection<String> supportedAnnotationTypes() {
75 return supportedTypes;
76 }
78 public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
79 AnnotationProcessorEnvironment env) {
80 return new ErrorAP(env);
81 }
82 }