Tue, 26 Jan 2016 21:08:18 +0000
8130304: Inference: NodeNotFoundException thrown with deep generic method call chain
Summary: Bug in Tarjan implementation is generating node ids which can overflow 32 bits
Reviewed-by: vromero
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;
180 public final Name.Table table;
182 public Names(Context context) {
183 Options options = Options.instance(context);
184 table = createTable(options);
186 // operators and punctuation
187 asterisk = fromString("*");
188 comma = fromString(",");
189 empty = fromString("");
190 hyphen = fromString("-");
191 one = fromString("1");
192 period = fromString(".");
193 semicolon = fromString(";");
194 slash = fromString("/");
195 slashequals = fromString("/=");
197 // keywords
198 _class = fromString("class");
199 _default = fromString("default");
200 _super = fromString("super");
201 _this = fromString("this");
203 // field and method names
204 _name = fromString("name");
205 addSuppressed = fromString("addSuppressed");
206 any = fromString("<any>");
207 append = fromString("append");
208 clinit = fromString("<clinit>");
209 clone = fromString("clone");
210 close = fromString("close");
211 compareTo = fromString("compareTo");
212 deserializeLambda = fromString("$deserializeLambda$");
213 desiredAssertionStatus = fromString("desiredAssertionStatus");
214 equals = fromString("equals");
215 error = fromString("<error>");
216 family = fromString("family");
217 finalize = fromString("finalize");
218 forName = fromString("forName");
219 getClass = fromString("getClass");
220 getClassLoader = fromString("getClassLoader");
221 getComponentType = fromString("getComponentType");
222 getDeclaringClass = fromString("getDeclaringClass");
223 getMessage = fromString("getMessage");
224 hasNext = fromString("hasNext");
225 hashCode = fromString("hashCode");
226 init = fromString("<init>");
227 initCause = fromString("initCause");
228 iterator = fromString("iterator");
229 length = fromString("length");
230 next = fromString("next");
231 ordinal = fromString("ordinal");
232 serialVersionUID = fromString("serialVersionUID");
233 toString = fromString("toString");
234 value = fromString("value");
235 valueOf = fromString("valueOf");
236 values = fromString("values");
238 // class names
239 java_io_Serializable = fromString("java.io.Serializable");
240 java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
241 java_lang_Class = fromString("java.lang.Class");
242 java_lang_Cloneable = fromString("java.lang.Cloneable");
243 java_lang_Enum = fromString("java.lang.Enum");
244 java_lang_Object = fromString("java.lang.Object");
245 java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
247 // names of builtin classes
248 Array = fromString("Array");
249 Bound = fromString("Bound");
250 Method = fromString("Method");
252 // package names
253 java_lang = fromString("java.lang");
255 // attribute names
256 Annotation = fromString("Annotation");
257 AnnotationDefault = fromString("AnnotationDefault");
258 BootstrapMethods = fromString("BootstrapMethods");
259 Bridge = fromString("Bridge");
260 CharacterRangeTable = fromString("CharacterRangeTable");
261 Code = fromString("Code");
262 CompilationID = fromString("CompilationID");
263 ConstantValue = fromString("ConstantValue");
264 Deprecated = fromString("Deprecated");
265 EnclosingMethod = fromString("EnclosingMethod");
266 Enum = fromString("Enum");
267 Exceptions = fromString("Exceptions");
268 InnerClasses = fromString("InnerClasses");
269 LineNumberTable = fromString("LineNumberTable");
270 LocalVariableTable = fromString("LocalVariableTable");
271 LocalVariableTypeTable = fromString("LocalVariableTypeTable");
272 MethodParameters = fromString("MethodParameters");
273 RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
274 RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
275 RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
276 RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
277 RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
278 RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
279 Signature = fromString("Signature");
280 SourceFile = fromString("SourceFile");
281 SourceID = fromString("SourceID");
282 StackMap = fromString("StackMap");
283 StackMapTable = fromString("StackMapTable");
284 Synthetic = fromString("Synthetic");
285 Value = fromString("Value");
286 Varargs = fromString("Varargs");
288 // members of java.lang.annotation.ElementType
289 ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
290 CONSTRUCTOR = fromString("CONSTRUCTOR");
291 FIELD = fromString("FIELD");
292 LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
293 METHOD = fromString("METHOD");
294 PACKAGE = fromString("PACKAGE");
295 PARAMETER = fromString("PARAMETER");
296 TYPE = fromString("TYPE");
297 TYPE_PARAMETER = fromString("TYPE_PARAMETER");
298 TYPE_USE = fromString("TYPE_USE");
300 // members of java.lang.annotation.RetentionPolicy
301 CLASS = fromString("CLASS");
302 RUNTIME = fromString("RUNTIME");
303 SOURCE = fromString("SOURCE");
305 // other identifiers
306 T = fromString("T");
307 deprecated = fromString("deprecated");
308 ex = fromString("ex");
309 package_info = fromString("package-info");
311 //lambda-related
312 lambda = fromString("lambda$");
313 metafactory = fromString("metafactory");
314 altMetafactory = fromString("altMetafactory");
315 }
317 protected Name.Table createTable(Options options) {
318 boolean useUnsharedTable = options.isSet("useUnsharedTable");
319 if (useUnsharedTable)
320 return new UnsharedNameTable(this);
321 else
322 return new SharedNameTable(this);
323 }
325 public void dispose() {
326 table.dispose();
327 }
329 public Name fromChars(char[] cs, int start, int len) {
330 return table.fromChars(cs, start, len);
331 }
333 public Name fromString(String s) {
334 return table.fromString(s);
335 }
337 public Name fromUtf(byte[] cs) {
338 return table.fromUtf(cs);
339 }
341 public Name fromUtf(byte[] cs, int start, int len) {
342 return table.fromUtf(cs, start, len);
343 }
344 }