APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.util

public Class SharedNameTable

extends Utf8NameTable
Class Inheritance
Imports
java.lang.ref.SoftReference, com.sun.tools.javac.util.DefinedBy.Api

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 supported API. 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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
public byte[]
bytes

The shared byte array holding all encountered names.

private static List<SoftReference<SharedNameTable>>
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'.

Constructor Summary

AccessConstructor and Description
public
SharedNameTable(Names
The main name table
names
,
int
the (constant) size to be used for the hash table needs to be a power of two.
hashSize
,
int
the initial size of the name table.
nameSize
)

Allocator

public

Method Summary

Modifier and TypeMethod and Description
private SharedNameTable.NameImpl
addName(int index, int len, int hash)

public static synchronized SharedNameTable
create(Names names)

private static synchronized void
public void
dispose()

Implements abstract com.sun.tools.javac.util.Name.Table.dispose.

Release any resources used by this table.

public Name
fromChars(char[] cs, int start, int len)

Implements abstract com.sun.tools.javac.util.Name.Table.fromChars.

Get the unique Name corresponding to the given characters.

public Name
fromUtf(byte[] cs, int start, int len, Convert.Validation validation)

Implements abstract com.sun.tools.javac.util.Name.Table.fromUtf.

Get the unique Name corresponding to the given Modified UTF-8 encoding.

Inherited from com.sun.tools.javac.util.Utf8NameTable:
equalshashValue

Field Detail

bytesback to summary
public byte[] bytes

The shared byte array holding all encountered names.

freelistback to summary
private static List<SoftReference<SharedNameTable>> freelist
hashesback to summary
private SharedNameTable.NameImpl[] hashes

The hash table for names.

hashMaskback to summary
private int hashMask

The mask to be used for hashing

ncback to summary
private int nc

The number of filled bytes in `names'.

Constructor Detail

SharedNameTableback to summary
public SharedNameTable(Names names, int hashSize, int nameSize)

Allocator

Parameters
names:Names

The main name table

hashSize:int

the (constant) size to be used for the hash table needs to be a power of two.

nameSize:int

the initial size of the name table.

Exceptions
IllegalArgumentException:
if hashSize is not a power of two
SharedNameTableback to summary
public SharedNameTable(Names names)

Method Detail

addNameback to summary
private SharedNameTable.NameImpl addName(int index, int len, int hash)
createback to summary
public static synchronized SharedNameTable create(Names names)
disposeback to summary
private static synchronized void dispose(SharedNameTable t)
disposeback to summary
public void dispose()

Implements abstract com.sun.tools.javac.util.Name.Table.dispose.

Doc from com.sun.tools.javac.util.Name.Table.dispose.

Release any resources used by this table.

Annotations
@Override
fromCharsback to summary
public Name fromChars(char[] cs, int start, int len)

Implements abstract com.sun.tools.javac.util.Name.Table.fromChars.

Doc from com.sun.tools.javac.util.Name.Table.fromChars.

Get the unique Name corresponding to the given characters.

Annotations
@Override
fromUtfback to summary
public Name fromUtf(byte[] cs, int start, int len, Convert.Validation validation) throws InvalidUtfException

Implements abstract com.sun.tools.javac.util.Name.Table.fromUtf.

Doc from com.sun.tools.javac.util.Name.Table.fromUtf.

Get the unique Name corresponding to the given Modified UTF-8 encoding.

Annotations
@Override
Exceptions
InvalidUtfException:
if invalid Modified UTF-8 is encountered
com.sun.tools.javac.util back to summary

pack-priv final Class SharedNameTable.NameImpl

extends NameImpl
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
index

The index where the bytes of this name are stored in the global name buffer `byte'.

pack-priv final int
length

The number of bytes in this name.

pack-priv final SharedNameTable.NameImpl
next

The next name occupying the same hash bucket.

Constructor Summary

AccessConstructor and Description
pack-priv
NameImpl(SharedNameTable table, int index, int length, SharedNameTable.NameImpl next)

Method Summary

Modifier and TypeMethod and Description
protected byte[]
getByteData()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteData.

Get the byte[] array in which the Modified UTF-8 data is stored.

protected int
getByteLength()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteLength.

Get the Modified UTF-8 data length in the byte array.

protected int
getByteOffset()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteOffset.

Get the Modified UTF-8 data offset into the byte array.

protected int
getNameIndex()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getNameIndex.

Get a unique index corresponding to this instance.

Inherited from com.sun.tools.javac.util.Utf8NameTable.NameImpl:
appendappendcompareTogetUtf8BytesgetUtf8LengthhashCodelastIndexOfAsciilengthnameEqualsstartsWithtoString

Field Detail

indexback to summary
pack-priv final int index

The index where the bytes of this name are stored in the global name buffer `byte'.

lengthback to summary
pack-priv final int length

The number of bytes in this name.

nextback to summary
pack-priv final SharedNameTable.NameImpl next

The next name occupying the same hash bucket.

Constructor Detail

NameImplback to summary
pack-priv NameImpl(SharedNameTable table, int index, int length, SharedNameTable.NameImpl next)

Method Detail

getByteDataback to summary
protected byte[] getByteData()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteData.

Doc from com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteData.

Get the byte[] array in which the Modified UTF-8 data is stored.

Annotations
@Override
getByteLengthback to summary
protected int getByteLength()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteLength.

Doc from com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteLength.

Get the Modified UTF-8 data length in the byte array.

Annotations
@Override
getByteOffsetback to summary
protected int getByteOffset()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteOffset.

Doc from com.sun.tools.javac.util.Utf8NameTable.NameImpl.getByteOffset.

Get the Modified UTF-8 data offset into the byte array.

Annotations
@Override
getNameIndexback to summary
protected int getNameIndex()

Implements abstract com.sun.tools.javac.util.Utf8NameTable.NameImpl.getNameIndex.

Doc from com.sun.tools.javac.util.Utf8NameTable.NameImpl.getNameIndex.

Get a unique index corresponding to this instance.

Annotations
@Override