Mon, 11 Apr 2011 16:31:22 -0700
Merge
jjg@113 | 1 | /* |
ohair@962 | 2 | * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
jjg@113 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@113 | 4 | * |
jjg@113 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@113 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
jjg@113 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
jjg@113 | 10 | * |
jjg@113 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@113 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@113 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@113 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@113 | 15 | * accompanied this code). |
jjg@113 | 16 | * |
jjg@113 | 17 | * You should have received a copy of the GNU General Public License version |
jjg@113 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@113 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@113 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
jjg@113 | 24 | */ |
jjg@113 | 25 | |
jjg@113 | 26 | package com.sun.tools.javac.util; |
jjg@113 | 27 | |
jjg@113 | 28 | /** |
jjg@113 | 29 | * Access to the compiler's name table. STandard names are defined, |
jjg@113 | 30 | * as well as methods to create new names. |
jjg@113 | 31 | * |
jjg@581 | 32 | * <p><b>This is NOT part of any supported API. |
jjg@581 | 33 | * If you write code that depends on this, you do so at your own risk. |
jjg@113 | 34 | * This code and its internal interfaces are subject to change or |
jjg@113 | 35 | * deletion without notice.</b> |
jjg@113 | 36 | */ |
jjg@113 | 37 | public class Names { |
jjg@113 | 38 | |
jjg@113 | 39 | public static final Context.Key<Names> namesKey = new Context.Key<Names>(); |
jjg@113 | 40 | |
jjg@113 | 41 | public static Names instance(Context context) { |
jjg@113 | 42 | Names instance = context.get(namesKey); |
jjg@113 | 43 | if (instance == null) { |
jjg@113 | 44 | instance = new Names(context); |
jjg@113 | 45 | context.put(namesKey, instance); |
jjg@113 | 46 | } |
jjg@113 | 47 | return instance; |
jjg@113 | 48 | } |
jjg@113 | 49 | |
jjg@113 | 50 | public final Name slash; |
jjg@113 | 51 | public final Name hyphen; |
jjg@113 | 52 | public final Name T; |
jjg@113 | 53 | public final Name slashequals; |
jjg@113 | 54 | public final Name deprecated; |
jjg@113 | 55 | public final Name init; |
jjg@113 | 56 | public final Name clinit; |
jjg@113 | 57 | public final Name error; |
jjg@113 | 58 | public final Name any; |
jjg@113 | 59 | public final Name empty; |
jjg@113 | 60 | public final Name one; |
jjg@113 | 61 | public final Name period; |
jjg@113 | 62 | public final Name comma; |
jjg@113 | 63 | public final Name semicolon; |
jjg@113 | 64 | public final Name asterisk; |
jjg@113 | 65 | public final Name _this; |
jjg@113 | 66 | public final Name _super; |
jjg@113 | 67 | public final Name _default; |
jjg@113 | 68 | public final Name _class; |
jjg@113 | 69 | public final Name java_lang; |
jjg@113 | 70 | public final Name java_lang_Object; |
jjg@113 | 71 | public final Name java_lang_Class; |
jjg@113 | 72 | public final Name java_lang_Cloneable; |
jjg@113 | 73 | public final Name java_io_Serializable; |
jjg@113 | 74 | public final Name serialVersionUID; |
jjg@113 | 75 | public final Name java_lang_Enum; |
mcimadamore@857 | 76 | public final Name transient_java_dyn_MethodHandle; // transient - 292 |
mcimadamore@857 | 77 | public final Name java_lang_invoke_MethodHandle; |
jjg@113 | 78 | public final Name package_info; |
jjg@113 | 79 | public final Name ConstantValue; |
jjg@113 | 80 | public final Name LineNumberTable; |
jjg@113 | 81 | public final Name LocalVariableTable; |
jjg@113 | 82 | public final Name LocalVariableTypeTable; |
jjg@113 | 83 | public final Name CharacterRangeTable; |
jjg@113 | 84 | public final Name StackMap; |
jjg@113 | 85 | public final Name StackMapTable; |
jjg@113 | 86 | public final Name SourceID; |
jjg@113 | 87 | public final Name CompilationID; |
jjg@113 | 88 | public final Name Code; |
jjg@113 | 89 | public final Name Exceptions; |
jjg@113 | 90 | public final Name SourceFile; |
jjg@113 | 91 | public final Name InnerClasses; |
jjg@113 | 92 | public final Name Synthetic; |
jjg@113 | 93 | public final Name Bridge; |
jjg@113 | 94 | public final Name Deprecated; |
jjg@113 | 95 | public final Name Enum; |
jjg@113 | 96 | public final Name _name; |
jjg@113 | 97 | public final Name Signature; |
jjg@113 | 98 | public final Name Varargs; |
jjg@113 | 99 | public final Name Annotation; |
jjg@113 | 100 | public final Name RuntimeVisibleAnnotations; |
jjg@113 | 101 | public final Name RuntimeInvisibleAnnotations; |
jjg@308 | 102 | public final Name RuntimeVisibleTypeAnnotations; |
jjg@308 | 103 | public final Name RuntimeInvisibleTypeAnnotations; |
jjg@113 | 104 | public final Name RuntimeVisibleParameterAnnotations; |
jjg@113 | 105 | public final Name RuntimeInvisibleParameterAnnotations; |
jjg@113 | 106 | public final Name Value; |
jjg@113 | 107 | public final Name EnclosingMethod; |
jjg@113 | 108 | public final Name desiredAssertionStatus; |
jjg@113 | 109 | public final Name append; |
jjg@113 | 110 | public final Name family; |
jjg@113 | 111 | public final Name forName; |
jjg@113 | 112 | public final Name toString; |
jjg@113 | 113 | public final Name length; |
jjg@113 | 114 | public final Name valueOf; |
jjg@113 | 115 | public final Name value; |
jjg@113 | 116 | public final Name getMessage; |
jjg@113 | 117 | public final Name getClass; |
jjg@113 | 118 | public final Name TYPE; |
jjg@308 | 119 | public final Name TYPE_USE; |
jjg@308 | 120 | public final Name TYPE_PARAMETER; |
jjg@113 | 121 | public final Name FIELD; |
jjg@113 | 122 | public final Name METHOD; |
jjg@113 | 123 | public final Name PARAMETER; |
jjg@113 | 124 | public final Name CONSTRUCTOR; |
jjg@113 | 125 | public final Name LOCAL_VARIABLE; |
jjg@113 | 126 | public final Name ANNOTATION_TYPE; |
jjg@113 | 127 | public final Name PACKAGE; |
jjg@113 | 128 | public final Name SOURCE; |
jjg@113 | 129 | public final Name CLASS; |
jjg@113 | 130 | public final Name RUNTIME; |
jjg@113 | 131 | public final Name Array; |
jjg@113 | 132 | public final Name Method; |
jjg@113 | 133 | public final Name Bound; |
jjg@113 | 134 | public final Name clone; |
jjg@113 | 135 | public final Name getComponentType; |
jjg@113 | 136 | public final Name getClassLoader; |
jjg@113 | 137 | public final Name initCause; |
jjg@113 | 138 | public final Name values; |
jjg@113 | 139 | public final Name iterator; |
jjg@113 | 140 | public final Name hasNext; |
jjg@113 | 141 | public final Name next; |
jjg@113 | 142 | public final Name AnnotationDefault; |
jjg@113 | 143 | public final Name ordinal; |
jjg@113 | 144 | public final Name equals; |
jjg@113 | 145 | public final Name hashCode; |
jjg@113 | 146 | public final Name compareTo; |
jjg@113 | 147 | public final Name getDeclaringClass; |
jjg@113 | 148 | public final Name ex; |
jjg@113 | 149 | public final Name finalize; |
darcy@609 | 150 | public final Name java_lang_AutoCloseable; |
darcy@609 | 151 | public final Name close; |
darcy@745 | 152 | public final Name addSuppressed; |
jjg@113 | 153 | |
jjg@113 | 154 | public final Name.Table table; |
jjg@113 | 155 | |
jjg@113 | 156 | public Names(Context context) { |
jjg@113 | 157 | Options options = Options.instance(context); |
jjg@113 | 158 | table = createTable(options); |
jjg@113 | 159 | |
jjg@113 | 160 | slash = fromString("/"); |
jjg@113 | 161 | hyphen = fromString("-"); |
jjg@113 | 162 | T = fromString("T"); |
jjg@113 | 163 | slashequals = fromString("/="); |
jjg@113 | 164 | deprecated = fromString("deprecated"); |
jjg@113 | 165 | |
jjg@113 | 166 | init = fromString("<init>"); |
jjg@113 | 167 | clinit = fromString("<clinit>"); |
jjg@113 | 168 | error = fromString("<error>"); |
jjg@113 | 169 | any = fromString("<any>"); |
jjg@113 | 170 | empty = fromString(""); |
jjg@113 | 171 | one = fromString("1"); |
jjg@113 | 172 | period = fromString("."); |
jjg@113 | 173 | comma = fromString(","); |
jjg@113 | 174 | semicolon = fromString(";"); |
jjg@113 | 175 | asterisk = fromString("*"); |
jjg@113 | 176 | _this = fromString("this"); |
jjg@113 | 177 | _super = fromString("super"); |
jjg@113 | 178 | _default = fromString("default"); |
jjg@113 | 179 | |
jjg@113 | 180 | _class = fromString("class"); |
jjg@113 | 181 | java_lang = fromString("java.lang"); |
jjg@113 | 182 | java_lang_Object = fromString("java.lang.Object"); |
jjg@113 | 183 | java_lang_Class = fromString("java.lang.Class"); |
jjg@113 | 184 | java_lang_Cloneable = fromString("java.lang.Cloneable"); |
jjg@113 | 185 | java_io_Serializable = fromString("java.io.Serializable"); |
jjg@113 | 186 | java_lang_Enum = fromString("java.lang.Enum"); |
mcimadamore@857 | 187 | transient_java_dyn_MethodHandle = fromString("java.dyn.MethodHandle"); //transient - 292 |
mcimadamore@857 | 188 | java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle"); |
jjg@113 | 189 | package_info = fromString("package-info"); |
jjg@113 | 190 | serialVersionUID = fromString("serialVersionUID"); |
jjg@113 | 191 | ConstantValue = fromString("ConstantValue"); |
jjg@113 | 192 | LineNumberTable = fromString("LineNumberTable"); |
jjg@113 | 193 | LocalVariableTable = fromString("LocalVariableTable"); |
jjg@113 | 194 | LocalVariableTypeTable = fromString("LocalVariableTypeTable"); |
jjg@113 | 195 | CharacterRangeTable = fromString("CharacterRangeTable"); |
jjg@113 | 196 | StackMap = fromString("StackMap"); |
jjg@113 | 197 | StackMapTable = fromString("StackMapTable"); |
jjg@113 | 198 | SourceID = fromString("SourceID"); |
jjg@113 | 199 | CompilationID = fromString("CompilationID"); |
jjg@113 | 200 | Code = fromString("Code"); |
jjg@113 | 201 | Exceptions = fromString("Exceptions"); |
jjg@113 | 202 | SourceFile = fromString("SourceFile"); |
jjg@113 | 203 | InnerClasses = fromString("InnerClasses"); |
jjg@113 | 204 | Synthetic = fromString("Synthetic"); |
jjg@113 | 205 | Bridge = fromString("Bridge"); |
jjg@113 | 206 | Deprecated = fromString("Deprecated"); |
jjg@113 | 207 | Enum = fromString("Enum"); |
jjg@113 | 208 | _name = fromString("name"); |
jjg@113 | 209 | Signature = fromString("Signature"); |
jjg@113 | 210 | Varargs = fromString("Varargs"); |
jjg@113 | 211 | Annotation = fromString("Annotation"); |
jjg@113 | 212 | RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations"); |
jjg@113 | 213 | RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations"); |
jjg@308 | 214 | RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations"); |
jjg@308 | 215 | RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations"); |
jjg@113 | 216 | RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations"); |
jjg@113 | 217 | RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations"); |
jjg@113 | 218 | Value = fromString("Value"); |
jjg@113 | 219 | EnclosingMethod = fromString("EnclosingMethod"); |
jjg@113 | 220 | |
jjg@113 | 221 | desiredAssertionStatus = fromString("desiredAssertionStatus"); |
jjg@113 | 222 | |
jjg@113 | 223 | append = fromString("append"); |
jjg@113 | 224 | family = fromString("family"); |
jjg@113 | 225 | forName = fromString("forName"); |
jjg@113 | 226 | toString = fromString("toString"); |
jjg@113 | 227 | length = fromString("length"); |
jjg@113 | 228 | valueOf = fromString("valueOf"); |
jjg@113 | 229 | value = fromString("value"); |
jjg@113 | 230 | getMessage = fromString("getMessage"); |
jjg@113 | 231 | getClass = fromString("getClass"); |
jjg@113 | 232 | |
jjg@113 | 233 | TYPE = fromString("TYPE"); |
jjg@308 | 234 | TYPE_USE = fromString("TYPE_USE"); |
jjg@308 | 235 | TYPE_PARAMETER = fromString("TYPE_PARAMETER"); |
jjg@113 | 236 | FIELD = fromString("FIELD"); |
jjg@113 | 237 | METHOD = fromString("METHOD"); |
jjg@113 | 238 | PARAMETER = fromString("PARAMETER"); |
jjg@113 | 239 | CONSTRUCTOR = fromString("CONSTRUCTOR"); |
jjg@113 | 240 | LOCAL_VARIABLE = fromString("LOCAL_VARIABLE"); |
jjg@113 | 241 | ANNOTATION_TYPE = fromString("ANNOTATION_TYPE"); |
jjg@113 | 242 | PACKAGE = fromString("PACKAGE"); |
jjg@113 | 243 | |
jjg@113 | 244 | SOURCE = fromString("SOURCE"); |
jjg@113 | 245 | CLASS = fromString("CLASS"); |
jjg@113 | 246 | RUNTIME = fromString("RUNTIME"); |
jjg@113 | 247 | |
jjg@113 | 248 | Array = fromString("Array"); |
jjg@113 | 249 | Method = fromString("Method"); |
jjg@113 | 250 | Bound = fromString("Bound"); |
jjg@113 | 251 | clone = fromString("clone"); |
jjg@113 | 252 | getComponentType = fromString("getComponentType"); |
jjg@113 | 253 | getClassLoader = fromString("getClassLoader"); |
jjg@113 | 254 | initCause = fromString("initCause"); |
jjg@113 | 255 | values = fromString("values"); |
jjg@113 | 256 | iterator = fromString("iterator"); |
jjg@113 | 257 | hasNext = fromString("hasNext"); |
jjg@113 | 258 | next = fromString("next"); |
jjg@113 | 259 | AnnotationDefault = fromString("AnnotationDefault"); |
jjg@113 | 260 | ordinal = fromString("ordinal"); |
jjg@113 | 261 | equals = fromString("equals"); |
jjg@113 | 262 | hashCode = fromString("hashCode"); |
jjg@113 | 263 | compareTo = fromString("compareTo"); |
jjg@113 | 264 | getDeclaringClass = fromString("getDeclaringClass"); |
jjg@113 | 265 | ex = fromString("ex"); |
jjg@113 | 266 | finalize = fromString("finalize"); |
darcy@609 | 267 | |
darcy@609 | 268 | java_lang_AutoCloseable = fromString("java.lang.AutoCloseable"); |
darcy@609 | 269 | close = fromString("close"); |
darcy@745 | 270 | addSuppressed = fromString("addSuppressed"); |
jjg@113 | 271 | } |
jjg@113 | 272 | |
jjg@113 | 273 | protected Name.Table createTable(Options options) { |
jjg@700 | 274 | boolean useUnsharedTable = options.isSet("useUnsharedTable"); |
jjg@113 | 275 | if (useUnsharedTable) |
jjg@113 | 276 | return new UnsharedNameTable(this); |
jjg@113 | 277 | else |
jjg@113 | 278 | return new SharedNameTable(this); |
jjg@113 | 279 | } |
jjg@113 | 280 | |
jjg@113 | 281 | public void dispose() { |
jjg@113 | 282 | table.dispose(); |
jjg@113 | 283 | } |
jjg@113 | 284 | |
jjg@113 | 285 | public Name fromChars(char[] cs, int start, int len) { |
jjg@113 | 286 | return table.fromChars(cs, start, len); |
jjg@113 | 287 | } |
jjg@113 | 288 | |
jjg@113 | 289 | public Name fromString(String s) { |
jjg@113 | 290 | return table.fromString(s); |
jjg@113 | 291 | } |
jjg@113 | 292 | |
jjg@113 | 293 | public Name fromUtf(byte[] cs) { |
jjg@113 | 294 | return table.fromUtf(cs); |
jjg@113 | 295 | } |
jjg@113 | 296 | |
jjg@113 | 297 | public Name fromUtf(byte[] cs, int start, int len) { |
jjg@113 | 298 | return table.fromUtf(cs, start, len); |
jjg@113 | 299 | } |
jjg@113 | 300 | } |