ConstantPool Struct Reference

#include <Class.h>

List of all members.


Detailed Description

The constant pool of a class and related operations.

The structure covers all operations that may be required to run on the constant pool, such as parsing and processing queries.


Public Member Functions

 ConstantPool ()
 Initializes the constant pool to its initial values.
 ~ConstantPool ()
 Clears constant pool content (if there are any).
bool available () const
 Checks whether the constant pool is not empty.
uint16 get_size () const
 Gets the size of the given constant pool.
bool is_valid_index (uint16 index) const
 Checks whether the index is a valid one in the constant pool.
bool is_entry_resolved (uint16 index) const
 Checks whether the constant-pool entry is resolved.
bool is_entry_in_error (uint16 index) const
 Checks whether the resolution of the constant-pool entry has failed.
bool is_utf8 (uint16 index) const
 Checks whether the constant-pool entry represents the string of the CONSTANT_Utf8 type.
bool is_class (uint16 index) const
 Checks whether the constant-pool entry refers to a CONSTANT_Class.
bool is_constant (uint16 index) const
 Checks whether the constant-pool entry contains a constant.
bool is_string (uint16 index) const
 Checks whether the constant-pool entry is a literal constant.
bool is_name_and_type (uint16 index) const
 Checks whether the constant-pool entry is CONSTANT_NameAndType.
bool is_fieldref (uint16 index) const
 Checks whether the constant-pool entry contains a field reference, CONSTANT_Fieldref.
bool is_methodref (uint16 index) const
 Checks whether the constant-pool entry contains a method reference, CONSTANT_Methodref.
bool is_interfacemethodref (uint16 index) const
 Checks whether the constant-pool entry constains an interface-method reference, CONSTANT_InterfaceMethodref.
unsigned char get_tag (uint16 index) const
 Gets a tag of the referenced constant-pool entry.
const char * get_utf8_chars (uint16 index) const
 Gets characters from the utf8 string stored in the constant pool.
Stringget_utf8_string (uint16 index) const
 Gets the utf8 string stored in the constant pool.
const char * get_string_chars (uint16 index) const
 Gets characters stored in the utf8 string for the CONSTANT_String entry.
Stringget_string (uint16 index) const
 Gets the utf8 string stored for the CONSTANT_String entry.
Stringget_name_and_type_name (uint16 index) const
 Gets the utf8 string representing the name part of the name-and-type constant-pool entry.
Stringget_name_and_type_descriptor (uint16 index) const
 Gets the utf8 string representing the descriptor part of the name-and-type constant-pool entry.
Class_Memberget_ref_class_member (uint16 index) const
 Gets the generic class member for the CONSTANT_*ref constant-pool entry.
Methodget_ref_method (uint16 index) const
 Gets the method from the CONSTANT_Methodref or the CONSTANT_InterfaceMethodref constant-pool entry.
Fieldget_ref_field (uint16 index) const
 Gets the field from the CONSTANT_Fieldref constant-pool entry.
Classget_class_class (uint16 index) const
 Gets the class for the CONSTANT_Class constant-pool entry.
uint32 get_4byte (uint16 index) const
 Gets a 32-bit value (either interger or float) for a constant stored in the constant pool.
uint32 get_int (uint16 index) const
 Gets an integer value for a constant stored in the constant pool.
float get_float (uint16 index) const
 Gets a float value for a constant stored in the constant pool.
uint32 get_8byte_low_word (uint16 index) const
 Gets a low word of the 64-bit constant (either long or double) stored in the constant pool.
uint32 get_8byte_high_word (uint16 index) const
 Gets a high word of the 64-bit constant (either long or double) stored in the constant pool.
void * get_address_of_constant (uint16 index) const
 Gets an address of a constant stored in the constant pool.
jthrowable get_error_cause (uint16 index) const
 Gets an exception, which has caused failure of the referred constant-pool entry.
ConstPoolEntryget_error_chain () const
 Gets a head of a single-linked list containing resolution errors in the given constant pool.
uint16 get_string_index (uint16 index) const
 Gets an an index in the constant pool where the utf8 representation for CONSTANT_String is stored.
uint16 get_name_and_type_name_index (uint16 index) const
 Gets an index of the constant-pool entry containing the utf8 string with the name part.
uint16 get_name_and_type_descriptor_index (uint16 index) const
 Gets an index of the constant-pool entry containing the utf8 string with the descriptor part.
uint16 get_ref_class_index (uint16 index) const
 Gets an index of the constant-pool entry containing a class for the given CONSTANT_*ref entry.
uint16 get_ref_name_and_type_index (uint16 index) const
 Gets an index of CONSTANT_NameAndType for the given constant-pool entry.
uint16 get_class_name_index (uint16 index) const
 Gets a class-name an index in the constant pool for the CONSTANT_Class entry.
void resolve_entry (uint16 index, Class *clss)
 Resolves an entry to the class.
void resolve_entry (uint16 index, Field *field)
 Resolves an entry to the field.
void resolve_entry (uint16 index, Method *method)
 Resolves an entry to the method.
void resolve_as_error (uint16 index, jthrowable exn)
 Records a resolution error into a constant-pool entry.
bool parse (Class *clss, String_Pool &string_pool, ByteReader &cfs)
 Parses in a constant pool for a class.
bool check (Global_Env *env, Class *clss, bool is_trusted_cl)
 Checks constant pool consistency.
void clear ()
 Clears the constant-pool content: tags and entries arrays.
void init ()
 Initializes the constant pool to initial values.


Constructor & Destructor Documentation

ConstantPool.ConstantPool (  ) 

Initializes the constant pool to its initial values.

ConstantPool.~ConstantPool (  ) 

Clears constant pool content (if there are any).


Member Function Documentation

bool ConstantPool.available (  )  const

Checks whether the constant pool is not empty.

Returns:
true if the constant pool contains certain entries; otherwise false.

uint16 ConstantPool.get_size (  )  const

Gets the size of the given constant pool.

Returns:
The number of entries in the constant pool.

bool ConstantPool.is_valid_index ( uint16  index  )  const

Checks whether the index is a valid one in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the index is a valid one in the constant pool; otherwise false.

bool ConstantPool.is_entry_resolved ( uint16  index  )  const

Checks whether the constant-pool entry is resolved.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the entry is resolved; otherwise false.

bool ConstantPool.is_entry_in_error ( uint16  index  )  const

Checks whether the resolution of the constant-pool entry has failed.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the resolution error is recorded for the entry.

bool ConstantPool.is_utf8 ( uint16  index  )  const

Checks whether the constant-pool entry represents the string of the CONSTANT_Utf8 type.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry is the utf8 string; otherwise false.

bool ConstantPool.is_class ( uint16  index  )  const

Checks whether the constant-pool entry refers to a CONSTANT_Class.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry is a class; otherwise false.

bool ConstantPool.is_constant ( uint16  index  )  const

Checks whether the constant-pool entry contains a constant.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry contains a constant; otherwise false.

bool ConstantPool.is_string ( uint16  index  )  const

Checks whether the constant-pool entry is a literal constant.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry contains a string; otherwise false.

bool ConstantPool.is_name_and_type ( uint16  index  )  const

Checks whether the constant-pool entry is CONSTANT_NameAndType.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry contains name-and-type; otherwise false.

bool ConstantPool.is_fieldref ( uint16  index  )  const

Checks whether the constant-pool entry contains a field reference, CONSTANT_Fieldref.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry contains a field reference; otherwise false.

bool ConstantPool.is_methodref ( uint16  index  )  const

Checks whether the constant-pool entry contains a method reference, CONSTANT_Methodref.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry contains a method reference; otherwise false.

bool ConstantPool.is_interfacemethodref ( uint16  index  )  const

Checks whether the constant-pool entry constains an interface-method reference, CONSTANT_InterfaceMethodref.

Parameters:
[in] index - an index in the constant pool
Returns:
true if the given entry contains an interface-method reference; otherwise false.

unsigned char ConstantPool.get_tag ( uint16  index  )  const

Gets a tag of the referenced constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
A constant-pool entry tag for a given index.

const char* ConstantPool.get_utf8_chars ( uint16  index  )  const

Gets characters from the utf8 string stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
Characters from the utf8 string stored in the constant pool.

String* ConstantPool.get_utf8_string ( uint16  index  )  const

Gets the utf8 string stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
The utf8 string.

const char* ConstantPool.get_string_chars ( uint16  index  )  const

Gets characters stored in the utf8 string for the CONSTANT_String entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The utf8 string characters for the given constant-pool entry.

String* ConstantPool.get_string ( uint16  index  )  const

Gets the utf8 string stored for the CONSTANT_String entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The utf8 string stored in the constant-pool entry.

String* ConstantPool.get_name_and_type_name ( uint16  index  )  const

Gets the utf8 string representing the name part of the name-and-type constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The utf8 string with the name part.

String* ConstantPool.get_name_and_type_descriptor ( uint16  index  )  const

Gets the utf8 string representing the descriptor part of the name-and-type constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The utf8 string with the descriptor part.

Class_Member* ConstantPool.get_ref_class_member ( uint16  index  )  const

Gets the generic class member for the CONSTANT_*ref constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The generic-class member for the given constant-pool entry.

Method* ConstantPool.get_ref_method ( uint16  index  )  const

Gets the method from the CONSTANT_Methodref or the CONSTANT_InterfaceMethodref constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The method from the given constant-pool entry.

Field* ConstantPool.get_ref_field ( uint16  index  )  const

Gets the field from the CONSTANT_Fieldref constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The field from the given constant-pool entry.

Class* ConstantPool.get_class_class ( uint16  index  )  const

Gets the class for the CONSTANT_Class constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
The class for the given constant-pool entry.

uint32 ConstantPool.get_4byte ( uint16  index  )  const

Gets a 32-bit value (either interger or float) for a constant stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
The value of a 32-bit constant stored in the constant pool.

uint32 ConstantPool.get_int ( uint16  index  )  const

Gets an integer value for a constant stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
The value of integer constant stored in the constant pool.

float ConstantPool.get_float ( uint16  index  )  const

Gets a float value for a constant stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
A value of a float constant stored in the constant pool.

uint32 ConstantPool.get_8byte_low_word ( uint16  index  )  const

Gets a low word of the 64-bit constant (either long or double) stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
A value of low 32-bits of 64-bit constant.

uint32 ConstantPool.get_8byte_high_word ( uint16  index  )  const

Gets a high word of the 64-bit constant (either long or double) stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
A value of high 32-bits of 64-bit constant.

void* ConstantPool.get_address_of_constant ( uint16  index  )  const

Gets an address of a constant stored in the constant pool.

Parameters:
[in] index - an index in the constant pool
Returns:
An address of a constant.

jthrowable ConstantPool.get_error_cause ( uint16  index  )  const

Gets an exception, which has caused failure of the referred constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
An exception object, which is the cause of the resolution failure.

ConstPoolEntry* ConstantPool.get_error_chain (  )  const

Gets a head of a single-linked list containing resolution errors in the given constant pool.

Returns:
A head of a signle-linked list of constant-pool entries, which resolution had failed.

uint16 ConstantPool.get_string_index ( uint16  index  )  const

Gets an an index in the constant pool where the utf8 representation for CONSTANT_String is stored.

Parameters:
[in] index - an index in the constant pool for the CONSTANT_String entry
Returns:
An an index in the constant pool with the utf8 representation of the given string.

uint16 ConstantPool.get_name_and_type_name_index ( uint16  index  )  const

Gets an index of the constant-pool entry containing the utf8 string with the name part.

Parameters:
[in] index - an index in the constant pool
Returns:
An an index in the constant pool with the utf8 name string.

uint16 ConstantPool.get_name_and_type_descriptor_index ( uint16  index  )  const

Gets an index of the constant-pool entry containing the utf8 string with the descriptor part.

Parameters:
[in] index - an index in the constant pool
Returns:
An an index in the constant pool with the utf8 string for the descriptor.

uint16 ConstantPool.get_ref_class_index ( uint16  index  )  const

Gets an index of the constant-pool entry containing a class for the given CONSTANT_*ref entry.

Parameters:
[in] index - an index in the constant pool
Returns:
An index of a class entry for the given constant-pool entry.

uint16 ConstantPool.get_ref_name_and_type_index ( uint16  index  )  const

Gets an index of CONSTANT_NameAndType for the given constant-pool entry.

Parameters:
[in] index - an index in the constant pool
Returns:
An index of CONSTANT_NameAndType for the given constant-pool entry.

uint16 ConstantPool.get_class_name_index ( uint16  index  )  const

Gets a class-name an index in the constant pool for the CONSTANT_Class entry.

Parameters:
[in] index - an index in the constant pool
Returns:
An index of the utf8 name of the given class.

void ConstantPool.resolve_entry ( uint16  index,
Class clss 
)

Resolves an entry to the class.

Parameters:
[in] index - an index in the constant pool
[in] clss - a class to resolve the given entry to

void ConstantPool.resolve_entry ( uint16  index,
Field field 
)

Resolves an entry to the field.

Parameters:
[in] index - an index in the constant pool
[in] field - a field to resolve the given entry to

void ConstantPool.resolve_entry ( uint16  index,
Method method 
)

Resolves an entry to the method.

Parameters:
[in] index - an index in the constant pool
[in] method - a method to resolve the given entry to

void ConstantPool.resolve_as_error ( uint16  index,
jthrowable  exn 
)

Records a resolution error into a constant-pool entry.

Parameters:
[in] index - an index in the constant pool
[in] exn - a cause of resolution failure
Note:
Disable suspension during this operation.

bool ConstantPool.parse ( Class clss,
String_Pool string_pool,
ByteReader cfs 
)

Parses in a constant pool for a class.

Parameters:
[in] clss - a class containing the given constant pool
[in] string_pool - a reference to the string pool to intern strings in
[in] cfs - a byte stream to parse the constant pool from
Returns:
true if the constant pool was parsed successfully; false if some error was discovered during the parsing.

bool ConstantPool.check ( Global_Env env,
Class clss,
bool  is_trusted_cl 
)

Checks constant pool consistency.

Parameters:
[in] env - VM environment
[in] clss - the class that the given constant pool belongs to
[in] is_trusted_cl - defines whether class was loaded by trusted classloader. User defined classloaders are not trusted.
Returns:
true if the constant pool of clss is valid; otherwise false.

void ConstantPool.clear (  ) 

Clears the constant-pool content: tags and entries arrays.

void ConstantPool.init (  ) 

Initializes the constant pool to initial values.


The documentation for this struct was generated from the following file:

Genereated on Tue Mar 11 19:26:00 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.