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