Wed, 13 Apr 2011 16:57:22 -0700
Merge
1 /*
2 * Copyright (c) 1999, 2011, 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 public final Name slash;
51 public final Name hyphen;
52 public final Name T;
53 public final Name slashequals;
54 public final Name deprecated;
55 public final Name init;
56 public final Name clinit;
57 public final Name error;
58 public final Name any;
59 public final Name empty;
60 public final Name one;
61 public final Name period;
62 public final Name comma;
63 public final Name semicolon;
64 public final Name asterisk;
65 public final Name _this;
66 public final Name _super;
67 public final Name _default;
68 public final Name _class;
69 public final Name java_lang;
70 public final Name java_lang_Object;
71 public final Name java_lang_Class;
72 public final Name java_lang_Cloneable;
73 public final Name java_io_Serializable;
74 public final Name serialVersionUID;
75 public final Name java_lang_Enum;
76 public final Name java_lang_invoke_MethodHandle;
77 public final Name package_info;
78 public final Name ConstantValue;
79 public final Name LineNumberTable;
80 public final Name LocalVariableTable;
81 public final Name LocalVariableTypeTable;
82 public final Name CharacterRangeTable;
83 public final Name StackMap;
84 public final Name StackMapTable;
85 public final Name SourceID;
86 public final Name CompilationID;
87 public final Name Code;
88 public final Name Exceptions;
89 public final Name SourceFile;
90 public final Name InnerClasses;
91 public final Name Synthetic;
92 public final Name Bridge;
93 public final Name Deprecated;
94 public final Name Enum;
95 public final Name _name;
96 public final Name Signature;
97 public final Name Varargs;
98 public final Name Annotation;
99 public final Name RuntimeVisibleAnnotations;
100 public final Name RuntimeInvisibleAnnotations;
101 public final Name RuntimeVisibleTypeAnnotations;
102 public final Name RuntimeInvisibleTypeAnnotations;
103 public final Name RuntimeVisibleParameterAnnotations;
104 public final Name RuntimeInvisibleParameterAnnotations;
105 public final Name Value;
106 public final Name EnclosingMethod;
107 public final Name desiredAssertionStatus;
108 public final Name append;
109 public final Name family;
110 public final Name forName;
111 public final Name toString;
112 public final Name length;
113 public final Name valueOf;
114 public final Name value;
115 public final Name getMessage;
116 public final Name getClass;
117 public final Name TYPE;
118 public final Name TYPE_USE;
119 public final Name TYPE_PARAMETER;
120 public final Name FIELD;
121 public final Name METHOD;
122 public final Name PARAMETER;
123 public final Name CONSTRUCTOR;
124 public final Name LOCAL_VARIABLE;
125 public final Name ANNOTATION_TYPE;
126 public final Name PACKAGE;
127 public final Name SOURCE;
128 public final Name CLASS;
129 public final Name RUNTIME;
130 public final Name Array;
131 public final Name Method;
132 public final Name Bound;
133 public final Name clone;
134 public final Name getComponentType;
135 public final Name getClassLoader;
136 public final Name initCause;
137 public final Name values;
138 public final Name iterator;
139 public final Name hasNext;
140 public final Name next;
141 public final Name AnnotationDefault;
142 public final Name ordinal;
143 public final Name equals;
144 public final Name hashCode;
145 public final Name compareTo;
146 public final Name getDeclaringClass;
147 public final Name ex;
148 public final Name finalize;
149 public final Name java_lang_AutoCloseable;
150 public final Name close;
151 public final Name addSuppressed;
153 public final Name.Table table;
155 public Names(Context context) {
156 Options options = Options.instance(context);
157 table = createTable(options);
159 slash = fromString("/");
160 hyphen = fromString("-");
161 T = fromString("T");
162 slashequals = fromString("/=");
163 deprecated = fromString("deprecated");
165 init = fromString("<init>");
166 clinit = fromString("<clinit>");
167 error = fromString("<error>");
168 any = fromString("<any>");
169 empty = fromString("");
170 one = fromString("1");
171 period = fromString(".");
172 comma = fromString(",");
173 semicolon = fromString(";");
174 asterisk = fromString("*");
175 _this = fromString("this");
176 _super = fromString("super");
177 _default = fromString("default");
179 _class = fromString("class");
180 java_lang = fromString("java.lang");
181 java_lang_Object = fromString("java.lang.Object");
182 java_lang_Class = fromString("java.lang.Class");
183 java_lang_Cloneable = fromString("java.lang.Cloneable");
184 java_io_Serializable = fromString("java.io.Serializable");
185 java_lang_Enum = fromString("java.lang.Enum");
186 java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
187 package_info = fromString("package-info");
188 serialVersionUID = fromString("serialVersionUID");
189 ConstantValue = fromString("ConstantValue");
190 LineNumberTable = fromString("LineNumberTable");
191 LocalVariableTable = fromString("LocalVariableTable");
192 LocalVariableTypeTable = fromString("LocalVariableTypeTable");
193 CharacterRangeTable = fromString("CharacterRangeTable");
194 StackMap = fromString("StackMap");
195 StackMapTable = fromString("StackMapTable");
196 SourceID = fromString("SourceID");
197 CompilationID = fromString("CompilationID");
198 Code = fromString("Code");
199 Exceptions = fromString("Exceptions");
200 SourceFile = fromString("SourceFile");
201 InnerClasses = fromString("InnerClasses");
202 Synthetic = fromString("Synthetic");
203 Bridge = fromString("Bridge");
204 Deprecated = fromString("Deprecated");
205 Enum = fromString("Enum");
206 _name = fromString("name");
207 Signature = fromString("Signature");
208 Varargs = fromString("Varargs");
209 Annotation = fromString("Annotation");
210 RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
211 RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
212 RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
213 RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
214 RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
215 RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
216 Value = fromString("Value");
217 EnclosingMethod = fromString("EnclosingMethod");
219 desiredAssertionStatus = fromString("desiredAssertionStatus");
221 append = fromString("append");
222 family = fromString("family");
223 forName = fromString("forName");
224 toString = fromString("toString");
225 length = fromString("length");
226 valueOf = fromString("valueOf");
227 value = fromString("value");
228 getMessage = fromString("getMessage");
229 getClass = fromString("getClass");
231 TYPE = fromString("TYPE");
232 TYPE_USE = fromString("TYPE_USE");
233 TYPE_PARAMETER = fromString("TYPE_PARAMETER");
234 FIELD = fromString("FIELD");
235 METHOD = fromString("METHOD");
236 PARAMETER = fromString("PARAMETER");
237 CONSTRUCTOR = fromString("CONSTRUCTOR");
238 LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
239 ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
240 PACKAGE = fromString("PACKAGE");
242 SOURCE = fromString("SOURCE");
243 CLASS = fromString("CLASS");
244 RUNTIME = fromString("RUNTIME");
246 Array = fromString("Array");
247 Method = fromString("Method");
248 Bound = fromString("Bound");
249 clone = fromString("clone");
250 getComponentType = fromString("getComponentType");
251 getClassLoader = fromString("getClassLoader");
252 initCause = fromString("initCause");
253 values = fromString("values");
254 iterator = fromString("iterator");
255 hasNext = fromString("hasNext");
256 next = fromString("next");
257 AnnotationDefault = fromString("AnnotationDefault");
258 ordinal = fromString("ordinal");
259 equals = fromString("equals");
260 hashCode = fromString("hashCode");
261 compareTo = fromString("compareTo");
262 getDeclaringClass = fromString("getDeclaringClass");
263 ex = fromString("ex");
264 finalize = fromString("finalize");
266 java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
267 close = fromString("close");
268 addSuppressed = fromString("addSuppressed");
269 }
271 protected Name.Table createTable(Options options) {
272 boolean useUnsharedTable = options.isSet("useUnsharedTable");
273 if (useUnsharedTable)
274 return new UnsharedNameTable(this);
275 else
276 return new SharedNameTable(this);
277 }
279 public void dispose() {
280 table.dispose();
281 }
283 public Name fromChars(char[] cs, int start, int len) {
284 return table.fromChars(cs, start, len);
285 }
287 public Name fromString(String s) {
288 return table.fromString(s);
289 }
291 public Name fromUtf(byte[] cs) {
292 return table.fromUtf(cs);
293 }
295 public Name fromUtf(byte[] cs, int start, int len) {
296 return table.fromUtf(cs, start, len);
297 }
298 }