Thu, 15 Nov 2012 23:07:24 -0800
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
Reviewed-by: darcy
1 /*
2 * Copyright (c) 1999, 2012, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.javac.util;
28 /**
29 * Access to the compiler's name table. STandard names are defined,
30 * as well as methods to create new names.
31 *
32 * <p><b>This is NOT part of any supported API.
33 * If you write code that depends on this, you do so at your own risk.
34 * This code and its internal interfaces are subject to change or
35 * deletion without notice.</b>
36 */
37 public class Names {
39 public static final Context.Key<Names> namesKey = new Context.Key<Names>();
41 public static Names instance(Context context) {
42 Names instance = context.get(namesKey);
43 if (instance == null) {
44 instance = new Names(context);
45 context.put(namesKey, instance);
46 }
47 return instance;
48 }
50 // operators and punctuation
51 public final Name asterisk;
52 public final Name comma;
53 public final Name empty;
54 public final Name hyphen;
55 public final Name one;
56 public final Name period;
57 public final Name semicolon;
58 public final Name slash;
59 public final Name slashequals;
61 // keywords
62 public final Name _class;
63 public final Name _default;
64 public final Name _super;
65 public final Name _this;
67 // field and method names
68 public final Name _name;
69 public final Name addSuppressed;
70 public final Name any;
71 public final Name append;
72 public final Name clinit;
73 public final Name clone;
74 public final Name close;
75 public final Name compareTo;
76 public final Name desiredAssertionStatus;
77 public final Name equals;
78 public final Name error;
79 public final Name family;
80 public final Name finalize;
81 public final Name forName;
82 public final Name getClass;
83 public final Name getClassLoader;
84 public final Name getComponentType;
85 public final Name getDeclaringClass;
86 public final Name getMessage;
87 public final Name hasNext;
88 public final Name hashCode;
89 public final Name init;
90 public final Name initCause;
91 public final Name iterator;
92 public final Name length;
93 public final Name next;
94 public final Name ordinal;
95 public final Name serialVersionUID;
96 public final Name toString;
97 public final Name value;
98 public final Name valueOf;
99 public final Name values;
101 // class names
102 public final Name java_io_Serializable;
103 public final Name java_lang_AutoCloseable;
104 public final Name java_lang_Class;
105 public final Name java_lang_Cloneable;
106 public final Name java_lang_Enum;
107 public final Name java_lang_Object;
108 public final Name java_lang_invoke_MethodHandle;
110 // names of builtin classes
111 public final Name Array;
112 public final Name Bound;
113 public final Name Method;
115 // package names
116 public final Name java_lang;
118 // attribute names
119 public final Name Annotation;
120 public final Name AnnotationDefault;
121 public final Name BootstrapMethods;
122 public final Name Bridge;
123 public final Name CharacterRangeTable;
124 public final Name Code;
125 public final Name CompilationID;
126 public final Name ConstantValue;
127 public final Name Deprecated;
128 public final Name EnclosingMethod;
129 public final Name Enum;
130 public final Name Exceptions;
131 public final Name InnerClasses;
132 public final Name LineNumberTable;
133 public final Name LocalVariableTable;
134 public final Name LocalVariableTypeTable;
135 public final Name RuntimeInvisibleAnnotations;
136 public final Name RuntimeInvisibleParameterAnnotations;
137 public final Name RuntimeInvisibleTypeAnnotations;
138 public final Name RuntimeVisibleAnnotations;
139 public final Name RuntimeVisibleParameterAnnotations;
140 public final Name RuntimeVisibleTypeAnnotations;
141 public final Name Signature;
142 public final Name SourceFile;
143 public final Name SourceID;
144 public final Name StackMap;
145 public final Name StackMapTable;
146 public final Name Synthetic;
147 public final Name Value;
148 public final Name Varargs;
150 // members of java.lang.annotation.ElementType
151 public final Name ANNOTATION_TYPE;
152 public final Name CONSTRUCTOR;
153 public final Name FIELD;
154 public final Name LOCAL_VARIABLE;
155 public final Name METHOD;
156 public final Name PACKAGE;
157 public final Name PARAMETER;
158 public final Name TYPE;
159 public final Name TYPE_PARAMETER;
160 public final Name TYPE_USE;
162 // members of java.lang.annotation.RetentionPolicy
163 public final Name CLASS;
164 public final Name RUNTIME;
165 public final Name SOURCE;
167 // other identifiers
168 public final Name T;
169 public final Name deprecated;
170 public final Name ex;
171 public final Name package_info;
173 //lambda-related
174 public final Name lambda;
175 public final Name metaFactory;
177 public final Name.Table table;
179 public Names(Context context) {
180 Options options = Options.instance(context);
181 table = createTable(options);
183 // operators and punctuation
184 asterisk = fromString("*");
185 comma = fromString(",");
186 empty = fromString("");
187 hyphen = fromString("-");
188 one = fromString("1");
189 period = fromString(".");
190 semicolon = fromString(";");
191 slash = fromString("/");
192 slashequals = fromString("/=");
194 // keywords
195 _class = fromString("class");
196 _default = fromString("default");
197 _super = fromString("super");
198 _this = fromString("this");
200 // field and method names
201 _name = fromString("name");
202 addSuppressed = fromString("addSuppressed");
203 any = fromString("<any>");
204 append = fromString("append");
205 clinit = fromString("<clinit>");
206 clone = fromString("clone");
207 close = fromString("close");
208 compareTo = fromString("compareTo");
209 desiredAssertionStatus = fromString("desiredAssertionStatus");
210 equals = fromString("equals");
211 error = fromString("<error>");
212 family = fromString("family");
213 finalize = fromString("finalize");
214 forName = fromString("forName");
215 getClass = fromString("getClass");
216 getClassLoader = fromString("getClassLoader");
217 getComponentType = fromString("getComponentType");
218 getDeclaringClass = fromString("getDeclaringClass");
219 getMessage = fromString("getMessage");
220 hasNext = fromString("hasNext");
221 hashCode = fromString("hashCode");
222 init = fromString("<init>");
223 initCause = fromString("initCause");
224 iterator = fromString("iterator");
225 length = fromString("length");
226 next = fromString("next");
227 ordinal = fromString("ordinal");
228 serialVersionUID = fromString("serialVersionUID");
229 toString = fromString("toString");
230 value = fromString("value");
231 valueOf = fromString("valueOf");
232 values = fromString("values");
234 // class names
235 java_io_Serializable = fromString("java.io.Serializable");
236 java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
237 java_lang_Class = fromString("java.lang.Class");
238 java_lang_Cloneable = fromString("java.lang.Cloneable");
239 java_lang_Enum = fromString("java.lang.Enum");
240 java_lang_Object = fromString("java.lang.Object");
241 java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
243 // names of builtin classes
244 Array = fromString("Array");
245 Bound = fromString("Bound");
246 Method = fromString("Method");
248 // package names
249 java_lang = fromString("java.lang");
251 // attribute names
252 Annotation = fromString("Annotation");
253 AnnotationDefault = fromString("AnnotationDefault");
254 BootstrapMethods = fromString("BootstrapMethods");
255 Bridge = fromString("Bridge");
256 CharacterRangeTable = fromString("CharacterRangeTable");
257 Code = fromString("Code");
258 CompilationID = fromString("CompilationID");
259 ConstantValue = fromString("ConstantValue");
260 Deprecated = fromString("Deprecated");
261 EnclosingMethod = fromString("EnclosingMethod");
262 Enum = fromString("Enum");
263 Exceptions = fromString("Exceptions");
264 InnerClasses = fromString("InnerClasses");
265 LineNumberTable = fromString("LineNumberTable");
266 LocalVariableTable = fromString("LocalVariableTable");
267 LocalVariableTypeTable = fromString("LocalVariableTypeTable");
268 RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
269 RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
270 RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
271 RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
272 RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
273 RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
274 Signature = fromString("Signature");
275 SourceFile = fromString("SourceFile");
276 SourceID = fromString("SourceID");
277 StackMap = fromString("StackMap");
278 StackMapTable = fromString("StackMapTable");
279 Synthetic = fromString("Synthetic");
280 Value = fromString("Value");
281 Varargs = fromString("Varargs");
283 // members of java.lang.annotation.ElementType
284 ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
285 CONSTRUCTOR = fromString("CONSTRUCTOR");
286 FIELD = fromString("FIELD");
287 LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
288 METHOD = fromString("METHOD");
289 PACKAGE = fromString("PACKAGE");
290 PARAMETER = fromString("PARAMETER");
291 TYPE = fromString("TYPE");
292 TYPE_PARAMETER = fromString("TYPE_PARAMETER");
293 TYPE_USE = fromString("TYPE_USE");
295 // members of java.lang.annotation.RetentionPolicy
296 CLASS = fromString("CLASS");
297 RUNTIME = fromString("RUNTIME");
298 SOURCE = fromString("SOURCE");
300 // other identifiers
301 T = fromString("T");
302 deprecated = fromString("deprecated");
303 ex = fromString("ex");
304 package_info = fromString("package-info");
306 //lambda-related
307 lambda = fromString("lambda");
308 metaFactory = fromString("metaFactory");
309 }
311 protected Name.Table createTable(Options options) {
312 boolean useUnsharedTable = options.isSet("useUnsharedTable");
313 if (useUnsharedTable)
314 return new UnsharedNameTable(this);
315 else
316 return new SharedNameTable(this);
317 }
319 public void dispose() {
320 table.dispose();
321 }
323 public Name fromChars(char[] cs, int start, int len) {
324 return table.fromChars(cs, start, len);
325 }
327 public Name fromString(String s) {
328 return table.fromString(s);
329 }
331 public Name fromUtf(byte[] cs) {
332 return table.fromUtf(cs);
333 }
335 public Name fromUtf(byte[] cs, int start, int len) {
336 return table.fromUtf(cs, start, len);
337 }
338 }