|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.classloader.Atom
public final class Atom
An utf8-encoded byte string.
Atom's are interned (canonicalized) so they may be compared for equality using the "==" operator.
Atoms are used to represent names, descriptors, and string literals appearing in a class's constant pool.
There is almost always a zero-length Atom, since any class which contains statements like:
return "";will have one in its constant pool.
Nested Class Summary | |
---|---|
private static class |
Atom.InternedStrings
Inner class responsible for string interning. |
Field Summary | |
---|---|
private static Atom[][] |
atoms
Dictionary of all Atom instances. |
private static byte[][] |
BOOTSTRAP_CLASS_PREFIX_SET
The set of class prefixes that MUST be loaded by bootstrap classloader. |
private static ImmutableEntryHashMapRVM<Atom,Atom> |
dictionary
Used to canonicalize Atoms: possibly non-canonical Atom => Atom |
private int |
id
The id of this atom |
private static int |
LOG_ROW_SIZE
2^LOG_ROW_SIZE is the number of elements per row |
private static int |
nextId
Used to assign ids. |
private static byte[][] |
NON_BOOTSTRAP_CLASS_PREFIX_SET
The set of class prefixes that MUST NOT be loaded by bootstrap classloader. |
private static int |
ROW_MASK
Mask to ascertain row from id number |
private static byte[][] |
RVM_CLASS_PREFIXES
The set of class prefixes for core RVM classes. |
private Object |
unicodeStringOrJTOCoffset
A reference to either a unicode String encoding the atom, an offset in the JTOC holding a unicode string encoding the atom or null. |
private byte[] |
val
The utf8 value this atom represents |
Constructor Summary | |
---|---|
private |
Atom(byte[] val,
int id,
String str)
Create atom from the key that maps to it. |
Method Summary | |
---|---|
String |
annotationClassToAnnotationInterface()
Create a class name from a type name. |
Atom |
annotationInterfaceToAnnotationClass()
Create an annotation name from a class name. |
(package private) Atom |
arrayDescriptorFromElementDescriptor()
Return array descriptor corresponding to "this" array-element descriptor. |
String |
classFileNameFromDescriptor()
Return name of class file corresponding to "this" class descriptor. |
String |
classNameFromDescriptor()
Return class name corresponding to "this" class descriptor. |
Atom |
descriptorFromClassName()
Return class descriptor corresponding to "this" class name. |
boolean |
equals(Object other)
Outside of this class atoms are canonical and should be compared using ==. |
static Atom |
findAsciiAtom(String str)
Find an atom. |
private static Atom |
findOrCreate(byte[] bytes,
boolean create,
String str)
This is the findOrCreate() method through which all Atoms are ultimately created. |
private static Atom |
findOrCreate(byte[] utf8,
int off,
int len,
String str)
Find an atom from the subsequence of another |
static Atom |
findOrCreateAsciiAtom(String str)
Find or create an atom. |
static Atom |
findOrCreateUnicodeAtom(String str)
Find or create an atom. |
static Atom |
findOrCreateUtf8Atom(byte[] utf8)
Find or create an atom. |
static Atom |
findUnicodeAtom(String str)
Find an atom. |
static Atom |
findUtf8Atom(byte[] utf8)
Find an atom. |
static Atom |
getAtom(int id)
|
byte[] |
getBytes()
Return the underlying set of bytes for the Atom. |
(package private) int |
getId()
|
int |
getStringLiteralOffset()
Offset of an atom's string in the JTOC, for string literals |
int |
hashCode()
Return the hashCode of an atom, this equals the unicode string encoding of the atom |
static String |
internString(String str)
External string intern method called from String.intern. |
boolean |
isAnnotationClass()
Is this an annotation class name of the form Lfoo.bar$$; |
boolean |
isArrayDescriptor()
Is "this" atom an array descriptor? |
boolean |
isBootstrapClassDescriptor()
|
boolean |
isClassDescriptor()
Is "this" atom a class descriptor? |
boolean |
isMethodDescriptor()
Is "this" atom a method descriptor? |
boolean |
isReservedMemberName()
Is "this" atom a reserved member name? |
boolean |
isRVMDescriptor()
|
int |
length()
|
int |
parseForArrayDimensionality()
Parse "this" array descriptor to obtain number of dimensions in corresponding array type. |
Atom |
parseForArrayElementDescriptor()
Parse "this" array descriptor to obtain descriptor for array's element type. |
byte |
parseForArrayElementTypeCode()
Parse "this" array descriptor to obtain type code for its element type. |
Atom |
parseForInnermostArrayElementDescriptor()
Return the innermost element type reference for an array |
Class<?>[] |
parseForParameterClasses(ClassLoader cl)
Parse "this" method descriptor to obtain descriptions of method's parameters as classes. |
TypeReference[] |
parseForParameterTypes(ClassLoader cl)
Parse "this" method descriptor to obtain descriptions of method's parameters. |
TypeReference |
parseForReturnType(ClassLoader cl)
Parse "this" method descriptor to obtain description of method's return type. |
byte |
parseForTypeCode()
Parse "this" field, parameter, or return descriptor to obtain its type code. |
void |
sysWrite()
|
byte[] |
toByteArray()
Get at a string-like representation without doing any heap allocation. |
String |
toString()
Return printable representation of "this" atom. |
String |
toUnicodeString()
Return atom as a string literal |
private String |
toUnicodeStringInternal()
Atom as string literal or null if atom hasn't been converted |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final ImmutableEntryHashMapRVM<Atom,Atom> dictionary
private static final int LOG_ROW_SIZE
private static final int ROW_MASK
private static Atom[][] atoms
private static int nextId
private Object unicodeStringOrJTOCoffset
private final byte[] val
private final int id
private static final byte[][] BOOTSTRAP_CLASS_PREFIX_SET
isBootstrapClassDescriptor()
private static final byte[][] NON_BOOTSTRAP_CLASS_PREFIX_SET
isBootstrapClassDescriptor()
private static final byte[][] RVM_CLASS_PREFIXES
isRVMDescriptor()
Constructor Detail |
---|
private Atom(byte[] val, int id, String str)
Method Detail |
---|
int getId()
public static Atom findOrCreateUnicodeAtom(String str)
str
- atom value, as string literal whose characters are unicode
public static Atom findUnicodeAtom(String str)
str
- atom value, as string literal whose characters are unicode
public static Atom findOrCreateAsciiAtom(String str)
str
- atom value, as string literal whose characters are from
ascii subset of unicode (not including null)
public static Atom findAsciiAtom(String str)
str
- atom value, as string literal whose characters are from
ascii subset of unicode (not including null)
public static Atom findOrCreateUtf8Atom(byte[] utf8)
utf8
- atom value, as utf8 encoded bytes
public static Atom findUtf8Atom(byte[] utf8)
utf8
- atom value, as utf8 encoded bytes
private static Atom findOrCreate(byte[] utf8, int off, int len, String str)
utf8
- byte backing of atomoff
- offset of new atomlen
- length of new atomstr
- possible string encoding of atom or null
private static Atom findOrCreate(byte[] bytes, boolean create, String str)
public static Atom getAtom(int id)
id
- the id of an Atom
public String toString()
toString
in class Object
public byte[] toByteArray()
public String toUnicodeString() throws UTFDataFormatException
UTFDataFormatException
private String toUnicodeStringInternal()
public int getStringLiteralOffset() throws UTFDataFormatException
UTFDataFormatException
Atom arrayDescriptorFromElementDescriptor()
public Atom descriptorFromClassName()
public String classNameFromDescriptor()
public String classFileNameFromDescriptor()
public boolean isReservedMemberName()
public boolean isClassDescriptor()
public boolean isArrayDescriptor()
public boolean isMethodDescriptor()
public TypeReference parseForReturnType(ClassLoader cl)
public TypeReference[] parseForParameterTypes(ClassLoader cl)
public Class<?>[] parseForParameterClasses(ClassLoader cl)
public byte[] getBytes()
public byte parseForTypeCode() throws IllegalArgumentException
constant value ---------------- ----- ClassTypeCode 'L' ArrayTypeCode '[' VoidTypeCode 'V' BooleanTypeCode 'Z' ByteTypeCode 'B' ShortTypeCode 'S' IntTypeCode 'I' LongTypeCode 'J' FloatTypeCode 'F' DoubleTypeCode 'D' CharTypeCode 'C'
IllegalArgumentException
public int parseForArrayDimensionality()
public byte parseForArrayElementTypeCode()
public Atom parseForInnermostArrayElementDescriptor()
public Atom parseForArrayElementDescriptor()
public boolean isBootstrapClassDescriptor()
public boolean isRVMDescriptor()
public Atom annotationInterfaceToAnnotationClass()
public String annotationClassToAnnotationInterface()
public boolean isAnnotationClass()
public void sysWrite()
public int length()
public int hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public static String internString(String str)
str
- string to intern
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |