Wed, 09 Apr 2008 13:41:45 +0100
5009937: hiding versus generics versus binary compatibility
Summary: missing implementation of JLS 8.4.8.3 (different arguments with same erasure not always triggering a compiler error)
Reviewed-by: jjg
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.javac.util; |
duke@1 | 27 | |
duke@1 | 28 | import java.lang.ref.SoftReference; |
duke@1 | 29 | |
duke@1 | 30 | |
duke@1 | 31 | /** An abstraction for internal compiler strings. For efficiency reasons, |
duke@1 | 32 | * GJC uses hashed strings that are stored in a common large buffer. |
duke@1 | 33 | * |
duke@1 | 34 | * <p>Names represent unique hashable strings. Two names are equal |
duke@1 | 35 | * if their indices are equal. Utf8 representation is used |
duke@1 | 36 | * for storing names internally. |
duke@1 | 37 | * |
duke@1 | 38 | * <p><b>This is NOT part of any API supported by Sun Microsystems. If |
duke@1 | 39 | * you write code that depends on this, you do so at your own risk. |
duke@1 | 40 | * This code and its internal interfaces are subject to change or |
duke@1 | 41 | * deletion without notice.</b> |
duke@1 | 42 | */ |
duke@1 | 43 | public class Name implements javax.lang.model.element.Name { |
duke@1 | 44 | |
duke@1 | 45 | /** The table structure where the name is stored |
duke@1 | 46 | */ |
duke@1 | 47 | public Table table; |
duke@1 | 48 | |
duke@1 | 49 | /** The index where the bytes of this name are stored in the global name |
duke@1 | 50 | * buffer `names'. |
duke@1 | 51 | */ |
duke@1 | 52 | public int index; |
duke@1 | 53 | |
duke@1 | 54 | /** The number of bytes in this name. |
duke@1 | 55 | */ |
duke@1 | 56 | public int len; |
duke@1 | 57 | |
duke@1 | 58 | /** The next name occupying the same hash bucket. |
duke@1 | 59 | */ |
duke@1 | 60 | Name next; |
duke@1 | 61 | |
duke@1 | 62 | /** The hashcode of a name. |
duke@1 | 63 | */ |
duke@1 | 64 | private static int hashValue(byte cs[], int start, int len) { |
duke@1 | 65 | int h = 0; |
duke@1 | 66 | int off = start; |
duke@1 | 67 | |
duke@1 | 68 | for (int i = 0; i < len; i++) { |
duke@1 | 69 | h = (h << 5) - h + cs[off++]; |
duke@1 | 70 | } |
duke@1 | 71 | return h; |
duke@1 | 72 | } |
duke@1 | 73 | |
duke@1 | 74 | /** Is (the utf8 representation of) name equal to |
duke@1 | 75 | * cs[start..start+len-1]? |
duke@1 | 76 | */ |
duke@1 | 77 | private static boolean equals(byte[] names, int index, |
duke@1 | 78 | byte cs[], int start, int len) { |
duke@1 | 79 | int i = 0; |
duke@1 | 80 | while (i < len && names[index + i] == cs[start + i]) i++; |
duke@1 | 81 | return i == len; |
duke@1 | 82 | } |
duke@1 | 83 | |
duke@1 | 84 | /** Create a name from the bytes in cs[start..start+len-1]. |
duke@1 | 85 | * Assume that bytes are in utf8 format. |
duke@1 | 86 | */ |
duke@1 | 87 | public static Name fromUtf(Table table, byte cs[], int start, int len) { |
duke@1 | 88 | int h = hashValue(cs, start, len) & table.hashMask; |
duke@1 | 89 | Name n = table.hashes[h]; |
duke@1 | 90 | byte[] names = table.names; |
duke@1 | 91 | while (n != null && |
duke@1 | 92 | (n.len != len || !equals(names, n.index, cs, start, len))) |
duke@1 | 93 | n = n.next; |
duke@1 | 94 | if (n == null) { |
duke@1 | 95 | int nc = table.nc; |
duke@1 | 96 | while (nc + len > names.length) { |
duke@1 | 97 | // System.err.println("doubling name buffer of length + " + names.length + " to fit " + len + " bytes");//DEBUG |
duke@1 | 98 | byte[] newnames = new byte[names.length * 2]; |
duke@1 | 99 | System.arraycopy(names, 0, newnames, 0, names.length); |
duke@1 | 100 | names = table.names = newnames; |
duke@1 | 101 | } |
duke@1 | 102 | System.arraycopy(cs, start, names, nc, len); |
duke@1 | 103 | n = new Name(); |
duke@1 | 104 | n.table = table; |
duke@1 | 105 | n.index = nc; |
duke@1 | 106 | n.len = len; |
duke@1 | 107 | n.next = table.hashes[h]; |
duke@1 | 108 | table.hashes[h] = n; |
duke@1 | 109 | table.nc = nc + len; |
duke@1 | 110 | if (len == 0) table.nc++; |
duke@1 | 111 | } |
duke@1 | 112 | return n; |
duke@1 | 113 | } |
duke@1 | 114 | |
duke@1 | 115 | /** Create a name from the bytes in array cs. |
duke@1 | 116 | * Assume that bytes are in utf8 format. |
duke@1 | 117 | */ |
duke@1 | 118 | public static Name fromUtf(Table table, byte cs[]) { |
duke@1 | 119 | return fromUtf(table, cs, 0, cs.length); |
duke@1 | 120 | } |
duke@1 | 121 | |
duke@1 | 122 | /** Create a name from the characters in cs[start..start+len-1]. |
duke@1 | 123 | */ |
duke@1 | 124 | public static Name fromChars(Table table, char[] cs, int start, int len) { |
duke@1 | 125 | int nc = table.nc; |
duke@1 | 126 | byte[] names = table.names; |
duke@1 | 127 | while (nc + len * 3 >= names.length) { |
duke@1 | 128 | // System.err.println("doubling name buffer of length " + names.length + " to fit " + len + " chars");//DEBUG |
duke@1 | 129 | byte[] newnames = new byte[names.length * 2]; |
duke@1 | 130 | System.arraycopy(names, 0, newnames, 0, names.length); |
duke@1 | 131 | names = table.names = newnames; |
duke@1 | 132 | } |
duke@1 | 133 | int nbytes = |
duke@1 | 134 | Convert.chars2utf(cs, start, names, nc, len) - nc; |
duke@1 | 135 | int h = hashValue(names, nc, nbytes) & table.hashMask; |
duke@1 | 136 | Name n = table.hashes[h]; |
duke@1 | 137 | while (n != null && |
duke@1 | 138 | (n.len != nbytes || |
duke@1 | 139 | !equals(names, n.index, names, nc, nbytes))) |
duke@1 | 140 | n = n.next; |
duke@1 | 141 | if (n == null) { |
duke@1 | 142 | n = new Name(); |
duke@1 | 143 | n.table = table; |
duke@1 | 144 | n.index = nc; |
duke@1 | 145 | n.len = nbytes; |
duke@1 | 146 | n.next = table.hashes[h]; |
duke@1 | 147 | table.hashes[h] = n; |
duke@1 | 148 | table.nc = nc + nbytes; |
duke@1 | 149 | if (nbytes == 0) table.nc++; |
duke@1 | 150 | } |
duke@1 | 151 | return n; |
duke@1 | 152 | } |
duke@1 | 153 | |
duke@1 | 154 | /** Create a name from the characters in string s. |
duke@1 | 155 | */ |
duke@1 | 156 | public static Name fromString(Table table, String s) { |
duke@1 | 157 | char[] cs = s.toCharArray(); |
duke@1 | 158 | return fromChars(table, cs, 0, cs.length); |
duke@1 | 159 | } |
duke@1 | 160 | |
duke@1 | 161 | /** Create a name from the characters in char sequence s. |
duke@1 | 162 | */ |
duke@1 | 163 | public static Name fromString(Table table, CharSequence s) { |
duke@1 | 164 | return fromString(table, s.toString()); |
duke@1 | 165 | } |
duke@1 | 166 | |
duke@1 | 167 | /** Return the Utf8 representation of this name. |
duke@1 | 168 | */ |
duke@1 | 169 | public byte[] toUtf() { |
duke@1 | 170 | byte[] bs = new byte[len]; |
duke@1 | 171 | System.arraycopy(table.names, index, bs, 0, len); |
duke@1 | 172 | return bs; |
duke@1 | 173 | } |
duke@1 | 174 | |
duke@1 | 175 | /** Return the string representation of this name. |
duke@1 | 176 | */ |
duke@1 | 177 | public String toString() { |
duke@1 | 178 | return Convert.utf2string(table.names, index, len); |
duke@1 | 179 | } |
duke@1 | 180 | |
duke@1 | 181 | /** Copy all bytes of this name to buffer cs, starting at start. |
duke@1 | 182 | */ |
duke@1 | 183 | public void getBytes(byte cs[], int start) { |
duke@1 | 184 | System.arraycopy(table.names, index, cs, start, len); |
duke@1 | 185 | } |
duke@1 | 186 | |
duke@1 | 187 | /** Return the hash value of this name. |
duke@1 | 188 | */ |
duke@1 | 189 | public int hashCode() { |
duke@1 | 190 | return index; |
duke@1 | 191 | } |
duke@1 | 192 | |
duke@1 | 193 | /** Is this name equal to other? |
duke@1 | 194 | */ |
duke@1 | 195 | public boolean equals(Object other) { |
duke@1 | 196 | if (other instanceof Name) |
duke@1 | 197 | return |
duke@1 | 198 | table == ((Name)other).table && index == ((Name)other).index; |
duke@1 | 199 | else return false; |
duke@1 | 200 | } |
duke@1 | 201 | |
duke@1 | 202 | /** Compare this name to other name, yielding -1 if smaller, 0 if equal, |
duke@1 | 203 | * 1 if greater. |
duke@1 | 204 | */ |
duke@1 | 205 | public boolean less(Name that) { |
duke@1 | 206 | int i = 0; |
duke@1 | 207 | while (i < this.len && i < that.len) { |
duke@1 | 208 | byte thisb = this.table.names[this.index + i]; |
duke@1 | 209 | byte thatb = that.table.names[that.index + i]; |
duke@1 | 210 | if (thisb < thatb) return true; |
duke@1 | 211 | else if (thisb > thatb) return false; |
duke@1 | 212 | else i++; |
duke@1 | 213 | } |
duke@1 | 214 | return this.len < that.len; |
duke@1 | 215 | } |
duke@1 | 216 | |
duke@1 | 217 | /** Returns the length of this name. |
duke@1 | 218 | */ |
duke@1 | 219 | public int length() { |
duke@1 | 220 | return toString().length(); |
duke@1 | 221 | } |
duke@1 | 222 | |
duke@1 | 223 | /** Returns i'th byte of this name. |
duke@1 | 224 | */ |
duke@1 | 225 | public byte byteAt(int i) { |
duke@1 | 226 | return table.names[index + i]; |
duke@1 | 227 | } |
duke@1 | 228 | |
duke@1 | 229 | /** Returns first occurrence of byte b in this name, len if not found. |
duke@1 | 230 | */ |
duke@1 | 231 | public int indexOf(byte b) { |
duke@1 | 232 | byte[] names = table.names; |
duke@1 | 233 | int i = 0; |
duke@1 | 234 | while (i < len && names[index + i] != b) i++; |
duke@1 | 235 | return i; |
duke@1 | 236 | } |
duke@1 | 237 | |
duke@1 | 238 | /** Returns last occurrence of byte b in this name, -1 if not found. |
duke@1 | 239 | */ |
duke@1 | 240 | public int lastIndexOf(byte b) { |
duke@1 | 241 | byte[] names = table.names; |
duke@1 | 242 | int i = len - 1; |
duke@1 | 243 | while (i >= 0 && names[index + i] != b) i--; |
duke@1 | 244 | return i; |
duke@1 | 245 | } |
duke@1 | 246 | |
duke@1 | 247 | /** Does this name start with prefix? |
duke@1 | 248 | */ |
duke@1 | 249 | public boolean startsWith(Name prefix) { |
duke@1 | 250 | int i = 0; |
duke@1 | 251 | while (i < prefix.len && |
duke@1 | 252 | i < len && |
duke@1 | 253 | table.names[index + i] == prefix.table.names[prefix.index + i]) |
duke@1 | 254 | i++; |
duke@1 | 255 | return i == prefix.len; |
duke@1 | 256 | } |
duke@1 | 257 | |
duke@1 | 258 | /** Does this name end with suffix? |
duke@1 | 259 | */ |
duke@1 | 260 | public boolean endsWith(Name suffix) { |
duke@1 | 261 | int i = len - 1; |
duke@1 | 262 | int j = suffix.len - 1; |
duke@1 | 263 | while (j >= 0 && i >= 0 && |
duke@1 | 264 | table.names[index + i] == suffix.table.names[suffix.index + j]) { |
duke@1 | 265 | i--; j--; |
duke@1 | 266 | } |
duke@1 | 267 | return j < 0; |
duke@1 | 268 | } |
duke@1 | 269 | |
duke@1 | 270 | /** Returns the sub-name starting at position start, up to and |
duke@1 | 271 | * excluding position end. |
duke@1 | 272 | */ |
duke@1 | 273 | public Name subName(int start, int end) { |
duke@1 | 274 | if (end < start) end = start; |
duke@1 | 275 | return fromUtf(table, table.names, index + start, end - start); |
duke@1 | 276 | } |
duke@1 | 277 | |
duke@1 | 278 | /** Replace all `from' bytes in this name with `to' bytes. |
duke@1 | 279 | */ |
duke@1 | 280 | public Name replace(byte from, byte to) { |
duke@1 | 281 | byte[] names = table.names; |
duke@1 | 282 | int i = 0; |
duke@1 | 283 | while (i < len) { |
duke@1 | 284 | if (names[index + i] == from) { |
duke@1 | 285 | byte[] bs = new byte[len]; |
duke@1 | 286 | System.arraycopy(names, index, bs, 0, i); |
duke@1 | 287 | bs[i] = to; |
duke@1 | 288 | i++; |
duke@1 | 289 | while (i < len) { |
duke@1 | 290 | byte b = names[index + i]; |
duke@1 | 291 | bs[i] = b == from ? to : b; |
duke@1 | 292 | i++; |
duke@1 | 293 | } |
duke@1 | 294 | return fromUtf(table, bs, 0, len); |
duke@1 | 295 | } |
duke@1 | 296 | i++; |
duke@1 | 297 | } |
duke@1 | 298 | return this; |
duke@1 | 299 | } |
duke@1 | 300 | |
duke@1 | 301 | /** Return the concatenation of this name and name `n'. |
duke@1 | 302 | */ |
duke@1 | 303 | public Name append(Name n) { |
duke@1 | 304 | byte[] bs = new byte[len + n.len]; |
duke@1 | 305 | getBytes(bs, 0); |
duke@1 | 306 | n.getBytes(bs, len); |
duke@1 | 307 | return fromUtf(table, bs, 0, bs.length); |
duke@1 | 308 | } |
duke@1 | 309 | |
duke@1 | 310 | /** Return the concatenation of this name, the given ASCII |
duke@1 | 311 | * character, and name `n'. |
duke@1 | 312 | */ |
duke@1 | 313 | public Name append(char c, Name n) { |
duke@1 | 314 | byte[] bs = new byte[len + n.len + 1]; |
duke@1 | 315 | getBytes(bs, 0); |
duke@1 | 316 | bs[len] = (byte)c; |
duke@1 | 317 | n.getBytes(bs, len+1); |
duke@1 | 318 | return fromUtf(table, bs, 0, bs.length); |
duke@1 | 319 | } |
duke@1 | 320 | |
duke@1 | 321 | /** An arbitrary but consistent complete order among all Names. |
duke@1 | 322 | */ |
duke@1 | 323 | public int compareTo(Name other) { |
duke@1 | 324 | return other.index - this.index; |
duke@1 | 325 | } |
duke@1 | 326 | |
duke@1 | 327 | /** Return the concatenation of all names in the array `ns'. |
duke@1 | 328 | */ |
duke@1 | 329 | public static Name concat(Table table, Name ns[]) { |
duke@1 | 330 | int len = 0; |
duke@1 | 331 | for (int i = 0; i < ns.length; i++) |
duke@1 | 332 | len = len + ns[i].len; |
duke@1 | 333 | byte[] bs = new byte[len]; |
duke@1 | 334 | len = 0; |
duke@1 | 335 | for (int i = 0; i < ns.length; i++) { |
duke@1 | 336 | ns[i].getBytes(bs, len); |
duke@1 | 337 | len = len + ns[i].len; |
duke@1 | 338 | } |
duke@1 | 339 | return fromUtf(table, bs, 0, len); |
duke@1 | 340 | } |
duke@1 | 341 | |
duke@1 | 342 | public char charAt(int index) { |
duke@1 | 343 | return toString().charAt(index); |
duke@1 | 344 | } |
duke@1 | 345 | |
duke@1 | 346 | public CharSequence subSequence(int start, int end) { |
duke@1 | 347 | return toString().subSequence(start, end); |
duke@1 | 348 | } |
duke@1 | 349 | |
duke@1 | 350 | public boolean contentEquals(CharSequence cs) { |
duke@1 | 351 | return this.toString().equals(cs.toString()); |
duke@1 | 352 | } |
duke@1 | 353 | |
duke@1 | 354 | public static class Table { |
duke@1 | 355 | // maintain a freelist of recently used name tables for reuse. |
duke@1 | 356 | private static List<SoftReference<Table>> freelist = List.nil(); |
duke@1 | 357 | |
duke@1 | 358 | static private synchronized Table make() { |
duke@1 | 359 | while (freelist.nonEmpty()) { |
duke@1 | 360 | Table t = freelist.head.get(); |
duke@1 | 361 | freelist = freelist.tail; |
duke@1 | 362 | if (t != null) return t; |
duke@1 | 363 | } |
duke@1 | 364 | return new Table(); |
duke@1 | 365 | } |
duke@1 | 366 | |
duke@1 | 367 | static private synchronized void dispose(Table t) { |
duke@1 | 368 | freelist = freelist.prepend(new SoftReference<Table>(t)); |
duke@1 | 369 | } |
duke@1 | 370 | |
duke@1 | 371 | public void dispose() { |
duke@1 | 372 | dispose(this); |
duke@1 | 373 | } |
duke@1 | 374 | |
duke@1 | 375 | public static final Context.Key<Table> namesKey = |
duke@1 | 376 | new Context.Key<Table>(); |
duke@1 | 377 | |
duke@1 | 378 | public static Table instance(Context context) { |
duke@1 | 379 | Table instance = context.get(namesKey); |
duke@1 | 380 | if (instance == null) { |
duke@1 | 381 | instance = make(); |
duke@1 | 382 | context.put(namesKey, instance); |
duke@1 | 383 | } |
duke@1 | 384 | return instance; |
duke@1 | 385 | } |
duke@1 | 386 | |
duke@1 | 387 | /** The hash table for names. |
duke@1 | 388 | */ |
duke@1 | 389 | private Name[] hashes; |
duke@1 | 390 | |
duke@1 | 391 | /** The array holding all encountered names. |
duke@1 | 392 | */ |
duke@1 | 393 | public byte[] names; |
duke@1 | 394 | |
duke@1 | 395 | /** The mask to be used for hashing |
duke@1 | 396 | */ |
duke@1 | 397 | private int hashMask; |
duke@1 | 398 | |
duke@1 | 399 | /** The number of filled bytes in `names'. |
duke@1 | 400 | */ |
duke@1 | 401 | private int nc = 0; |
duke@1 | 402 | |
duke@1 | 403 | /** Allocator |
duke@1 | 404 | * @param hashSize the (constant) size to be used for the hash table |
duke@1 | 405 | * needs to be a power of two. |
duke@1 | 406 | * @param nameSize the initial size of the name table. |
duke@1 | 407 | */ |
duke@1 | 408 | public Table(int hashSize, int nameSize) { |
duke@1 | 409 | hashMask = hashSize - 1; |
duke@1 | 410 | hashes = new Name[hashSize]; |
duke@1 | 411 | names = new byte[nameSize]; |
duke@1 | 412 | |
duke@1 | 413 | slash = fromString("/"); |
duke@1 | 414 | hyphen = fromString("-"); |
duke@1 | 415 | T = fromString("T"); |
duke@1 | 416 | slashequals = fromString("/="); |
duke@1 | 417 | deprecated = fromString("deprecated"); |
duke@1 | 418 | |
duke@1 | 419 | init = fromString("<init>"); |
duke@1 | 420 | clinit = fromString("<clinit>"); |
duke@1 | 421 | error = fromString("<error>"); |
duke@1 | 422 | any = fromString("<any>"); |
duke@1 | 423 | empty = fromString(""); |
duke@1 | 424 | one = fromString("1"); |
duke@1 | 425 | period = fromString("."); |
duke@1 | 426 | comma = fromString(","); |
duke@1 | 427 | semicolon = fromString(";"); |
duke@1 | 428 | asterisk = fromString("*"); |
duke@1 | 429 | _this = fromString("this"); |
duke@1 | 430 | _super = fromString("super"); |
duke@1 | 431 | _default = fromString("default"); |
duke@1 | 432 | |
duke@1 | 433 | _class = fromString("class"); |
duke@1 | 434 | java_lang = fromString("java.lang"); |
duke@1 | 435 | java_lang_Object = fromString("java.lang.Object"); |
duke@1 | 436 | java_lang_Class = fromString("java.lang.Class"); |
duke@1 | 437 | java_lang_Cloneable = fromString("java.lang.Cloneable"); |
duke@1 | 438 | java_io_Serializable = fromString("java.io.Serializable"); |
duke@1 | 439 | java_lang_Enum = fromString("java.lang.Enum"); |
duke@1 | 440 | package_info = fromString("package-info"); |
duke@1 | 441 | serialVersionUID = fromString("serialVersionUID"); |
duke@1 | 442 | ConstantValue = fromString("ConstantValue"); |
duke@1 | 443 | LineNumberTable = fromString("LineNumberTable"); |
duke@1 | 444 | LocalVariableTable = fromString("LocalVariableTable"); |
duke@1 | 445 | LocalVariableTypeTable = fromString("LocalVariableTypeTable"); |
duke@1 | 446 | CharacterRangeTable = fromString("CharacterRangeTable"); |
duke@1 | 447 | StackMap = fromString("StackMap"); |
duke@1 | 448 | StackMapTable = fromString("StackMapTable"); |
duke@1 | 449 | SourceID = fromString("SourceID"); |
duke@1 | 450 | CompilationID = fromString("CompilationID"); |
duke@1 | 451 | Code = fromString("Code"); |
duke@1 | 452 | Exceptions = fromString("Exceptions"); |
duke@1 | 453 | SourceFile = fromString("SourceFile"); |
duke@1 | 454 | InnerClasses = fromString("InnerClasses"); |
duke@1 | 455 | Synthetic = fromString("Synthetic"); |
duke@1 | 456 | Bridge= fromString("Bridge"); |
duke@1 | 457 | Deprecated = fromString("Deprecated"); |
duke@1 | 458 | Enum = fromString("Enum"); |
duke@1 | 459 | _name = fromString("name"); |
duke@1 | 460 | Signature = fromString("Signature"); |
duke@1 | 461 | Varargs = fromString("Varargs"); |
duke@1 | 462 | Annotation = fromString("Annotation"); |
duke@1 | 463 | RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations"); |
duke@1 | 464 | RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations"); |
duke@1 | 465 | RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations"); |
duke@1 | 466 | RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations"); |
duke@1 | 467 | Value = fromString("Value"); |
duke@1 | 468 | EnclosingMethod = fromString("EnclosingMethod"); |
duke@1 | 469 | |
duke@1 | 470 | desiredAssertionStatus = fromString("desiredAssertionStatus"); |
duke@1 | 471 | |
duke@1 | 472 | append = fromString("append"); |
duke@1 | 473 | family = fromString("family"); |
duke@1 | 474 | forName = fromString("forName"); |
duke@1 | 475 | toString = fromString("toString"); |
duke@1 | 476 | length = fromString("length"); |
duke@1 | 477 | valueOf = fromString("valueOf"); |
duke@1 | 478 | value = fromString("value"); |
duke@1 | 479 | getMessage = fromString("getMessage"); |
duke@1 | 480 | getClass = fromString("getClass"); |
duke@1 | 481 | |
duke@1 | 482 | TYPE = fromString("TYPE"); |
duke@1 | 483 | FIELD = fromString("FIELD"); |
duke@1 | 484 | METHOD = fromString("METHOD"); |
duke@1 | 485 | PARAMETER = fromString("PARAMETER"); |
duke@1 | 486 | CONSTRUCTOR = fromString("CONSTRUCTOR"); |
duke@1 | 487 | LOCAL_VARIABLE = fromString("LOCAL_VARIABLE"); |
duke@1 | 488 | ANNOTATION_TYPE = fromString("ANNOTATION_TYPE"); |
duke@1 | 489 | PACKAGE = fromString("PACKAGE"); |
duke@1 | 490 | |
duke@1 | 491 | SOURCE = fromString("SOURCE"); |
duke@1 | 492 | CLASS = fromString("CLASS"); |
duke@1 | 493 | RUNTIME = fromString("RUNTIME"); |
duke@1 | 494 | |
duke@1 | 495 | Array = fromString("Array"); |
duke@1 | 496 | Method = fromString("Method"); |
duke@1 | 497 | Bound = fromString("Bound"); |
duke@1 | 498 | clone = fromString("clone"); |
duke@1 | 499 | getComponentType = fromString("getComponentType"); |
duke@1 | 500 | getClassLoader = fromString("getClassLoader"); |
duke@1 | 501 | initCause = fromString("initCause"); |
duke@1 | 502 | values = fromString("values"); |
duke@1 | 503 | iterator = fromString("iterator"); |
duke@1 | 504 | hasNext = fromString("hasNext"); |
duke@1 | 505 | next = fromString("next"); |
duke@1 | 506 | AnnotationDefault = fromString("AnnotationDefault"); |
duke@1 | 507 | ordinal = fromString("ordinal"); |
duke@1 | 508 | equals = fromString("equals"); |
duke@1 | 509 | hashCode = fromString("hashCode"); |
duke@1 | 510 | compareTo = fromString("compareTo"); |
duke@1 | 511 | getDeclaringClass = fromString("getDeclaringClass"); |
duke@1 | 512 | ex = fromString("ex"); |
duke@1 | 513 | finalize = fromString("finalize"); |
duke@1 | 514 | } |
duke@1 | 515 | |
duke@1 | 516 | public Table() { |
duke@1 | 517 | this(0x8000, 0x20000); |
duke@1 | 518 | } |
duke@1 | 519 | |
duke@1 | 520 | /** Create a name from the bytes in cs[start..start+len-1]. |
duke@1 | 521 | * Assume that bytes are in utf8 format. |
duke@1 | 522 | */ |
duke@1 | 523 | public Name fromUtf(byte cs[], int start, int len) { |
duke@1 | 524 | return Name.fromUtf(this, cs, start, len); |
duke@1 | 525 | } |
duke@1 | 526 | |
duke@1 | 527 | /** Create a name from the bytes in array cs. |
duke@1 | 528 | * Assume that bytes are in utf8 format. |
duke@1 | 529 | */ |
duke@1 | 530 | public Name fromUtf(byte cs[]) { |
duke@1 | 531 | return Name.fromUtf(this, cs, 0, cs.length); |
duke@1 | 532 | } |
duke@1 | 533 | |
duke@1 | 534 | /** Create a name from the characters in cs[start..start+len-1]. |
duke@1 | 535 | */ |
duke@1 | 536 | public Name fromChars(char[] cs, int start, int len) { |
duke@1 | 537 | return Name.fromChars(this, cs, start, len); |
duke@1 | 538 | } |
duke@1 | 539 | |
duke@1 | 540 | /** Create a name from the characters in string s. |
duke@1 | 541 | */ |
duke@1 | 542 | public Name fromString(CharSequence s) { |
duke@1 | 543 | return Name.fromString(this, s); |
duke@1 | 544 | } |
duke@1 | 545 | |
duke@1 | 546 | public final Name slash; |
duke@1 | 547 | public final Name hyphen; |
duke@1 | 548 | public final Name T; |
duke@1 | 549 | public final Name slashequals; |
duke@1 | 550 | public final Name deprecated; |
duke@1 | 551 | |
duke@1 | 552 | public final Name init; |
duke@1 | 553 | public final Name clinit; |
duke@1 | 554 | public final Name error; |
duke@1 | 555 | public final Name any; |
duke@1 | 556 | public final Name empty; |
duke@1 | 557 | public final Name one; |
duke@1 | 558 | public final Name period; |
duke@1 | 559 | public final Name comma; |
duke@1 | 560 | public final Name semicolon; |
duke@1 | 561 | public final Name asterisk; |
duke@1 | 562 | public final Name _this; |
duke@1 | 563 | public final Name _super; |
duke@1 | 564 | public final Name _default; |
duke@1 | 565 | |
duke@1 | 566 | public final Name _class; |
duke@1 | 567 | public final Name java_lang; |
duke@1 | 568 | public final Name java_lang_Object; |
duke@1 | 569 | public final Name java_lang_Class; |
duke@1 | 570 | public final Name java_lang_Cloneable; |
duke@1 | 571 | public final Name java_io_Serializable; |
duke@1 | 572 | public final Name serialVersionUID; |
duke@1 | 573 | public final Name java_lang_Enum; |
duke@1 | 574 | public final Name package_info; |
duke@1 | 575 | public final Name ConstantValue; |
duke@1 | 576 | public final Name LineNumberTable; |
duke@1 | 577 | public final Name LocalVariableTable; |
duke@1 | 578 | public final Name LocalVariableTypeTable; |
duke@1 | 579 | public final Name CharacterRangeTable; |
duke@1 | 580 | public final Name StackMap; |
duke@1 | 581 | public final Name StackMapTable; |
duke@1 | 582 | public final Name SourceID; |
duke@1 | 583 | public final Name CompilationID; |
duke@1 | 584 | public final Name Code; |
duke@1 | 585 | public final Name Exceptions; |
duke@1 | 586 | public final Name SourceFile; |
duke@1 | 587 | public final Name InnerClasses; |
duke@1 | 588 | public final Name Synthetic; |
duke@1 | 589 | public final Name Bridge; |
duke@1 | 590 | public final Name Deprecated; |
duke@1 | 591 | public final Name Enum; |
duke@1 | 592 | public final Name _name; |
duke@1 | 593 | public final Name Signature; |
duke@1 | 594 | public final Name Varargs; |
duke@1 | 595 | public final Name Annotation; |
duke@1 | 596 | public final Name RuntimeVisibleAnnotations; |
duke@1 | 597 | public final Name RuntimeInvisibleAnnotations; |
duke@1 | 598 | public final Name RuntimeVisibleParameterAnnotations; |
duke@1 | 599 | public final Name RuntimeInvisibleParameterAnnotations; |
duke@1 | 600 | |
duke@1 | 601 | public final Name Value; |
duke@1 | 602 | public final Name EnclosingMethod; |
duke@1 | 603 | |
duke@1 | 604 | public final Name desiredAssertionStatus; |
duke@1 | 605 | |
duke@1 | 606 | public final Name append; |
duke@1 | 607 | public final Name family; |
duke@1 | 608 | public final Name forName; |
duke@1 | 609 | public final Name toString; |
duke@1 | 610 | public final Name length; |
duke@1 | 611 | public final Name valueOf; |
duke@1 | 612 | public final Name value; |
duke@1 | 613 | public final Name getMessage; |
duke@1 | 614 | public final Name getClass; |
duke@1 | 615 | |
duke@1 | 616 | public final Name TYPE; |
duke@1 | 617 | public final Name FIELD; |
duke@1 | 618 | public final Name METHOD; |
duke@1 | 619 | public final Name PARAMETER; |
duke@1 | 620 | public final Name CONSTRUCTOR; |
duke@1 | 621 | public final Name LOCAL_VARIABLE; |
duke@1 | 622 | public final Name ANNOTATION_TYPE; |
duke@1 | 623 | public final Name PACKAGE; |
duke@1 | 624 | |
duke@1 | 625 | public final Name SOURCE; |
duke@1 | 626 | public final Name CLASS; |
duke@1 | 627 | public final Name RUNTIME; |
duke@1 | 628 | |
duke@1 | 629 | public final Name Array; |
duke@1 | 630 | public final Name Method; |
duke@1 | 631 | public final Name Bound; |
duke@1 | 632 | public final Name clone; |
duke@1 | 633 | public final Name getComponentType; |
duke@1 | 634 | public final Name getClassLoader; |
duke@1 | 635 | public final Name initCause; |
duke@1 | 636 | public final Name values; |
duke@1 | 637 | public final Name iterator; |
duke@1 | 638 | public final Name hasNext; |
duke@1 | 639 | public final Name next; |
duke@1 | 640 | public final Name AnnotationDefault; |
duke@1 | 641 | public final Name ordinal; |
duke@1 | 642 | public final Name equals; |
duke@1 | 643 | public final Name hashCode; |
duke@1 | 644 | public final Name compareTo; |
duke@1 | 645 | public final Name getDeclaringClass; |
duke@1 | 646 | public final Name ex; |
duke@1 | 647 | public final Name finalize; |
duke@1 | 648 | } |
duke@1 | 649 | |
duke@1 | 650 | public boolean isEmpty() { |
duke@1 | 651 | return len == 0; |
duke@1 | 652 | } |
duke@1 | 653 | } |