Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe
1 /*
2 * Copyright (c) 1999, 2013, 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 deserializeLambda;
77 public final Name desiredAssertionStatus;
78 public final Name equals;
79 public final Name error;
80 public final Name family;
81 public final Name finalize;
82 public final Name forName;
83 public final Name getClass;
84 public final Name getClassLoader;
85 public final Name getComponentType;
86 public final Name getDeclaringClass;
87 public final Name getMessage;
88 public final Name hasNext;
89 public final Name hashCode;
90 public final Name init;
91 public final Name initCause;
92 public final Name iterator;
93 public final Name length;
94 public final Name next;
95 public final Name ordinal;
96 public final Name serialVersionUID;
97 public final Name toString;
98 public final Name value;
99 public final Name valueOf;
100 public final Name values;
102 // class names
103 public final Name java_io_Serializable;
104 public final Name java_lang_AutoCloseable;
105 public final Name java_lang_Class;
106 public final Name java_lang_Cloneable;
107 public final Name java_lang_Enum;
108 public final Name java_lang_Object;
109 public final Name java_lang_invoke_MethodHandle;
111 // names of builtin classes
112 public final Name Array;
113 public final Name Bound;
114 public final Name Method;
116 // package names
117 public final Name java_lang;
119 // attribute names
120 public final Name Annotation;
121 public final Name AnnotationDefault;
122 public final Name BootstrapMethods;
123 public final Name Bridge;
124 public final Name CharacterRangeTable;
125 public final Name Code;
126 public final Name CompilationID;
127 public final Name ConstantValue;
128 public final Name Deprecated;
129 public final Name EnclosingMethod;
130 public final Name Enum;
131 public final Name Exceptions;
132 public final Name InnerClasses;
133 public final Name LineNumberTable;
134 public final Name LocalVariableTable;
135 public final Name LocalVariableTypeTable;
136 public final Name MethodParameters;
137 public final Name RuntimeInvisibleAnnotations;
138 public final Name RuntimeInvisibleParameterAnnotations;
139 public final Name RuntimeInvisibleTypeAnnotations;
140 public final Name RuntimeVisibleAnnotations;
141 public final Name RuntimeVisibleParameterAnnotations;
142 public final Name RuntimeVisibleTypeAnnotations;
143 public final Name Signature;
144 public final Name SourceFile;
145 public final Name SourceID;
146 public final Name StackMap;
147 public final Name StackMapTable;
148 public final Name Synthetic;
149 public final Name Value;
150 public final Name Varargs;
152 // members of java.lang.annotation.ElementType
153 public final Name ANNOTATION_TYPE;
154 public final Name CONSTRUCTOR;
155 public final Name FIELD;
156 public final Name LOCAL_VARIABLE;
157 public final Name METHOD;
158 public final Name PACKAGE;
159 public final Name PARAMETER;
160 public final Name TYPE;
161 public final Name TYPE_PARAMETER;
162 public final Name TYPE_USE;
164 // members of java.lang.annotation.RetentionPolicy
165 public final Name CLASS;
166 public final Name RUNTIME;
167 public final Name SOURCE;
169 // other identifiers
170 public final Name T;
171 public final Name deprecated;
172 public final Name ex;
173 public final Name package_info;
175 //lambda-related
176 public final Name lambda;
177 public final Name metafactory;
178 public final Name altMetafactory;
179 public final Name dollarThis;
181 public final Name.Table table;
183 public Names(Context context) {
184 Options options = Options.instance(context);
185 table = createTable(options);
187 // operators and punctuation
188 asterisk = fromString("*");
189 comma = fromString(",");
190 empty = fromString("");
191 hyphen = fromString("-");
192 one = fromString("1");
193 period = fromString(".");
194 semicolon = fromString(";");
195 slash = fromString("/");
196 slashequals = fromString("/=");
198 // keywords
199 _class = fromString("class");
200 _default = fromString("default");
201 _super = fromString("super");
202 _this = fromString("this");
204 // field and method names
205 _name = fromString("name");
206 addSuppressed = fromString("addSuppressed");
207 any = fromString("<any>");
208 append = fromString("append");
209 clinit = fromString("<clinit>");
210 clone = fromString("clone");
211 close = fromString("close");
212 compareTo = fromString("compareTo");
213 deserializeLambda = fromString("$deserializeLambda$");
214 desiredAssertionStatus = fromString("desiredAssertionStatus");
215 equals = fromString("equals");
216 error = fromString("<error>");
217 family = fromString("family");
218 finalize = fromString("finalize");
219 forName = fromString("forName");
220 getClass = fromString("getClass");
221 getClassLoader = fromString("getClassLoader");
222 getComponentType = fromString("getComponentType");
223 getDeclaringClass = fromString("getDeclaringClass");
224 getMessage = fromString("getMessage");
225 hasNext = fromString("hasNext");
226 hashCode = fromString("hashCode");
227 init = fromString("<init>");
228 initCause = fromString("initCause");
229 iterator = fromString("iterator");
230 length = fromString("length");
231 next = fromString("next");
232 ordinal = fromString("ordinal");
233 serialVersionUID = fromString("serialVersionUID");
234 toString = fromString("toString");
235 value = fromString("value");
236 valueOf = fromString("valueOf");
237 values = fromString("values");
238 dollarThis = fromString("$this");
240 // class names
241 java_io_Serializable = fromString("java.io.Serializable");
242 java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
243 java_lang_Class = fromString("java.lang.Class");
244 java_lang_Cloneable = fromString("java.lang.Cloneable");
245 java_lang_Enum = fromString("java.lang.Enum");
246 java_lang_Object = fromString("java.lang.Object");
247 java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
249 // names of builtin classes
250 Array = fromString("Array");
251 Bound = fromString("Bound");
252 Method = fromString("Method");
254 // package names
255 java_lang = fromString("java.lang");
257 // attribute names
258 Annotation = fromString("Annotation");
259 AnnotationDefault = fromString("AnnotationDefault");
260 BootstrapMethods = fromString("BootstrapMethods");
261 Bridge = fromString("Bridge");
262 CharacterRangeTable = fromString("CharacterRangeTable");
263 Code = fromString("Code");
264 CompilationID = fromString("CompilationID");
265 ConstantValue = fromString("ConstantValue");
266 Deprecated = fromString("Deprecated");
267 EnclosingMethod = fromString("EnclosingMethod");
268 Enum = fromString("Enum");
269 Exceptions = fromString("Exceptions");
270 InnerClasses = fromString("InnerClasses");
271 LineNumberTable = fromString("LineNumberTable");
272 LocalVariableTable = fromString("LocalVariableTable");
273 LocalVariableTypeTable = fromString("LocalVariableTypeTable");
274 MethodParameters = fromString("MethodParameters");
275 RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
276 RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
277 RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
278 RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
279 RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
280 RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
281 Signature = fromString("Signature");
282 SourceFile = fromString("SourceFile");
283 SourceID = fromString("SourceID");
284 StackMap = fromString("StackMap");
285 StackMapTable = fromString("StackMapTable");
286 Synthetic = fromString("Synthetic");
287 Value = fromString("Value");
288 Varargs = fromString("Varargs");
290 // members of java.lang.annotation.ElementType
291 ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
292 CONSTRUCTOR = fromString("CONSTRUCTOR");
293 FIELD = fromString("FIELD");
294 LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
295 METHOD = fromString("METHOD");
296 PACKAGE = fromString("PACKAGE");
297 PARAMETER = fromString("PARAMETER");
298 TYPE = fromString("TYPE");
299 TYPE_PARAMETER = fromString("TYPE_PARAMETER");
300 TYPE_USE = fromString("TYPE_USE");
302 // members of java.lang.annotation.RetentionPolicy
303 CLASS = fromString("CLASS");
304 RUNTIME = fromString("RUNTIME");
305 SOURCE = fromString("SOURCE");
307 // other identifiers
308 T = fromString("T");
309 deprecated = fromString("deprecated");
310 ex = fromString("ex");
311 package_info = fromString("package-info");
313 //lambda-related
314 lambda = fromString("lambda$");
315 metafactory = fromString("metafactory");
316 altMetafactory = fromString("altMetafactory");
317 }
319 protected Name.Table createTable(Options options) {
320 boolean useUnsharedTable = options.isSet("useUnsharedTable");
321 if (useUnsharedTable)
322 return new UnsharedNameTable(this);
323 else
324 return new SharedNameTable(this);
325 }
327 public void dispose() {
328 table.dispose();
329 }
331 public Name fromChars(char[] cs, int start, int len) {
332 return table.fromChars(cs, start, len);
333 }
335 public Name fromString(String s) {
336 return table.fromString(s);
337 }
339 public Name fromUtf(byte[] cs) {
340 return table.fromUtf(cs);
341 }
343 public Name fromUtf(byte[] cs, int start, int len) {
344 return table.fromUtf(cs, start, len);
345 }
346 }