Fri, 28 Sep 2012 16:56:53 +0100
8000233: Fix issues in recent push
Summary: Forgot to incorporate review comments in pushed changesets
Reviewed-by: jjg
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 public final Name.Table table;
175 public Names(Context context) {
176 Options options = Options.instance(context);
177 table = createTable(options);
179 // operators and punctuation
180 asterisk = fromString("*");
181 comma = fromString(",");
182 empty = fromString("");
183 hyphen = fromString("-");
184 one = fromString("1");
185 period = fromString(".");
186 semicolon = fromString(";");
187 slash = fromString("/");
188 slashequals = fromString("/=");
190 // keywords
191 _class = fromString("class");
192 _default = fromString("default");
193 _super = fromString("super");
194 _this = fromString("this");
196 // field and method names
197 _name = fromString("name");
198 addSuppressed = fromString("addSuppressed");
199 any = fromString("<any>");
200 append = fromString("append");
201 clinit = fromString("<clinit>");
202 clone = fromString("clone");
203 close = fromString("close");
204 compareTo = fromString("compareTo");
205 desiredAssertionStatus = fromString("desiredAssertionStatus");
206 equals = fromString("equals");
207 error = fromString("<error>");
208 family = fromString("family");
209 finalize = fromString("finalize");
210 forName = fromString("forName");
211 getClass = fromString("getClass");
212 getClassLoader = fromString("getClassLoader");
213 getComponentType = fromString("getComponentType");
214 getDeclaringClass = fromString("getDeclaringClass");
215 getMessage = fromString("getMessage");
216 hasNext = fromString("hasNext");
217 hashCode = fromString("hashCode");
218 init = fromString("<init>");
219 initCause = fromString("initCause");
220 iterator = fromString("iterator");
221 length = fromString("length");
222 next = fromString("next");
223 ordinal = fromString("ordinal");
224 serialVersionUID = fromString("serialVersionUID");
225 toString = fromString("toString");
226 value = fromString("value");
227 valueOf = fromString("valueOf");
228 values = fromString("values");
230 // class names
231 java_io_Serializable = fromString("java.io.Serializable");
232 java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
233 java_lang_Class = fromString("java.lang.Class");
234 java_lang_Cloneable = fromString("java.lang.Cloneable");
235 java_lang_Enum = fromString("java.lang.Enum");
236 java_lang_Object = fromString("java.lang.Object");
237 java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
239 // names of builtin classes
240 Array = fromString("Array");
241 Bound = fromString("Bound");
242 Method = fromString("Method");
244 // package names
245 java_lang = fromString("java.lang");
247 // attribute names
248 Annotation = fromString("Annotation");
249 AnnotationDefault = fromString("AnnotationDefault");
250 BootstrapMethods = fromString("BootstrapMethods");
251 Bridge = fromString("Bridge");
252 CharacterRangeTable = fromString("CharacterRangeTable");
253 Code = fromString("Code");
254 CompilationID = fromString("CompilationID");
255 ConstantValue = fromString("ConstantValue");
256 Deprecated = fromString("Deprecated");
257 EnclosingMethod = fromString("EnclosingMethod");
258 Enum = fromString("Enum");
259 Exceptions = fromString("Exceptions");
260 InnerClasses = fromString("InnerClasses");
261 LineNumberTable = fromString("LineNumberTable");
262 LocalVariableTable = fromString("LocalVariableTable");
263 LocalVariableTypeTable = fromString("LocalVariableTypeTable");
264 RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
265 RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
266 RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
267 RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
268 RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
269 RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
270 Signature = fromString("Signature");
271 SourceFile = fromString("SourceFile");
272 SourceID = fromString("SourceID");
273 StackMap = fromString("StackMap");
274 StackMapTable = fromString("StackMapTable");
275 Synthetic = fromString("Synthetic");
276 Value = fromString("Value");
277 Varargs = fromString("Varargs");
279 // members of java.lang.annotation.ElementType
280 ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
281 CONSTRUCTOR = fromString("CONSTRUCTOR");
282 FIELD = fromString("FIELD");
283 LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
284 METHOD = fromString("METHOD");
285 PACKAGE = fromString("PACKAGE");
286 PARAMETER = fromString("PARAMETER");
287 TYPE = fromString("TYPE");
288 TYPE_PARAMETER = fromString("TYPE_PARAMETER");
289 TYPE_USE = fromString("TYPE_USE");
291 // members of java.lang.annotation.RetentionPolicy
292 CLASS = fromString("CLASS");
293 RUNTIME = fromString("RUNTIME");
294 SOURCE = fromString("SOURCE");
296 // other identifiers
297 T = fromString("T");
298 deprecated = fromString("deprecated");
299 ex = fromString("ex");
300 package_info = fromString("package-info");
301 }
303 protected Name.Table createTable(Options options) {
304 boolean useUnsharedTable = options.isSet("useUnsharedTable");
305 if (useUnsharedTable)
306 return new UnsharedNameTable(this);
307 else
308 return new SharedNameTable(this);
309 }
311 public void dispose() {
312 table.dispose();
313 }
315 public Name fromChars(char[] cs, int start, int len) {
316 return table.fromChars(cs, start, len);
317 }
319 public Name fromString(String s) {
320 return table.fromString(s);
321 }
323 public Name fromUtf(byte[] cs) {
324 return table.fromUtf(cs);
325 }
327 public Name fromUtf(byte[] cs, int start, int len) {
328 return table.fromUtf(cs, start, len);
329 }
330 }