com.sun.tools.javac.util
Class SharedNameTable

java.lang.Object
  extended by com.sun.tools.javac.util.Name.Table
      extended by com.sun.tools.javac.util.SharedNameTable

public class SharedNameTable
extends Name.Table

Implementation of Name.Table that stores all names in a single shared byte array, expanding it as needed. This avoids the overhead incurred by using an array of bytes for each name.

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Nested Class Summary
(package private) static class SharedNameTable.NameImpl
           
 
Field Summary
 byte[] bytes
          The shared byte array holding all encountered names.
private static List<java.lang.ref.SoftReference<SharedNameTable>> freelist
           
private  SharedNameTable.NameImpl[] hashes
          The hash table for names.
private  int hashMask
          The mask to be used for hashing
private  int nc
          The number of filled bytes in `names'.
 
Fields inherited from class com.sun.tools.javac.util.Name.Table
names
 
Constructor Summary
SharedNameTable(Names names)
           
SharedNameTable(Names names, int hashSize, int nameSize)
          Allocator
 
Method Summary
static SharedNameTable create(Names names)
           
 void dispose()
          Release any resources used by this table.
private static void dispose(SharedNameTable t)
           
 Name fromChars(char[] cs, int start, int len)
          Get the name from the characters in cs[start..start+len-1].
 Name fromUtf(byte[] cs, int start, int len)
          get the name for the bytes in cs[start..start+len-1].
 
Methods inherited from class com.sun.tools.javac.util.Name.Table
equals, fromString, fromUtf, hashValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freelist

private static List<java.lang.ref.SoftReference<SharedNameTable>> freelist

hashes

private SharedNameTable.NameImpl[] hashes
The hash table for names.


bytes

public byte[] bytes
The shared byte array holding all encountered names.


hashMask

private int hashMask
The mask to be used for hashing


nc

private int nc
The number of filled bytes in `names'.

Constructor Detail

SharedNameTable

public SharedNameTable(Names names,
                       int hashSize,
                       int nameSize)
Allocator

Parameters:
names - The main name table
hashSize - the (constant) size to be used for the hash table needs to be a power of two.
nameSize - the initial size of the name table.

SharedNameTable

public SharedNameTable(Names names)
Method Detail

create

public static SharedNameTable create(Names names)

dispose

private static void dispose(SharedNameTable t)

fromChars

public Name fromChars(char[] cs,
                      int start,
                      int len)
Description copied from class: Name.Table
Get the name from the characters in cs[start..start+len-1].

Specified by:
fromChars in class Name.Table

fromUtf

public Name fromUtf(byte[] cs,
                    int start,
                    int len)
Description copied from class: Name.Table
get the name for the bytes in cs[start..start+len-1]. Assume that bytes are in utf8 format.

Specified by:
fromUtf in class Name.Table

dispose

public void dispose()
Description copied from class: Name.Table
Release any resources used by this table.

Specified by:
dispose in class Name.Table