Index: vm/include/open/compmgr.h =================================================================== --- vm/include/open/compmgr.h (revision 487512) +++ vm/include/open/compmgr.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Alexei Fedotov - * @version $Revision: 1.1.2.2.4.3 $ - */ /** * @file @@ -72,52 +68,62 @@ struct _OpenComponent { /** - * Returns a component name. + * @return A component name. */ const char* (*GetName) (); /** - * Returns a component version which is numbers separated with dots. + * @return A component version which is numbers separated with dots. + * * Implementors must check a major version number for compatibility. */ const char* (*GetVersion) (); /** - * Returns human-readable description of the component. + * @return Human-readable description of the component. */ const char* (*GetDescription) (); /** - * Returns the human-readable vendor string, e. g., + * @return The human-readable vendor string, e. g., * name of the organization which provides this component. */ const char* (*GetVendor) (); /** * Queries optional properties. - * @param key property name - * @return a string, true/false for boolean properties + * + * @param key - property name + * + * @return A string, TRUE/FALSE for boolean + * properties. */ const char* (*GetProperty) (const char* key); /** - * Exposes a NULL terminated list of component-specific + * Exposes a NULL terminated list of component-specific * interface names for the given component. * * This default component interface is not included. - * @return a pointer to an internal component manager structure, - * which should not be modified or freed. + * + * @return A pointer to an internal component manager structure, + * which should not be modified or freed. */ const char** (*ListInterfaceNames) (); /** * Exposes a component interface. - * @param[out] p_intf on return, points to an interface handle - * @param intf_name an interface name - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @param[out] p_intf - on return, points to an interface handle + * @param intf_name - an interface name + * + * @return APR_SUCCESS if successful, otherwise a non-zero + * error code */ int (*GetInterface) (OpenInterfaceHandle* p_intf, const char* intf_name); /** * The call to this function frees all component resources. - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @return APR_SUCCESS if successful, otherwise a non-zero + * error code */ int (*Free) (); @@ -151,18 +157,23 @@ * initialization which is called by component manager when a * new instance is created. * - * @param[out] p_instance on return, points to handle of a new instance - * @param pool created by a component manager for a lifetime of - * the instance, the component could use the pool for allocation - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * @param[out] p_instance - on return, points to handle of a new instance + * @param pool - created by a component manager for a lifetime + * of the instance, the component could use the + * pool for allocation + * @return APR_SUCCESS if successful, otherwise a non-zero + * error code. */ int (*CreateInstance) (OpenInstanceHandle* p_instance, apr_pool_t* pool); /** * Free memory and other resources for a given instance. - * @param instance a handle of an instance to free - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @param instance - a handle of an instance to free + * + * @return APR_SUCCESS if successful, otherwise a + * non-zero error code. */ int (*FreeInstance) (OpenInstanceHandle instance); }; @@ -184,10 +195,13 @@ /** * Get a default interface of a registered component by name. - * @param[out] p_component on return, points to - * a handle of default component interface - * @param name a component name - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @param[out] p_component - on return, points to a handle of + * default component interface + * @param name - a component name + * + * @return APR_SUCCESS if successful, otherwise a + * non-zero error code */ int (*GetComponent) (OpenComponentHandle* p_component, const char* name); @@ -195,10 +209,13 @@ /** * Create a new component instance and register it in * a component manager. - * @param[out] p_instance on return, points to a handle of a newly - * created instance - * @param name a name of interface - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @param[out] p_instance - on return, points to a handle of a newly + * created instance + * @param name - a name of interface + * + * @return APR_SUCCESS if successful, otherwise a non-zero + * error code */ int (*CreateInstance) (OpenInstanceHandle* p_instance, const char* name); @@ -206,8 +223,11 @@ /** * Unregister the instance in a component manager, * free memory and other resources held by the instance. - * @param instance a handle to the instance to Free - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @param instance - a handle to the instance to Free + * + * @return APR_SUCCESS if successful, otherwise + * a non-zero error code */ int (*FreeInstance) (OpenInstanceHandle instance); @@ -220,12 +240,15 @@ /** * The generic component initialization function type. - * @param[out] p_component on return, points to a handle of a default - * component interface - * @param[out] p_allocator on return, points to a handle of a private - * instance allocation interface - * @param pool a memory pool with the component lifetime - * @return APR_SUCCESS if successful, otherwise a non-zero error code + * + * @param[out] p_component - on return, points to a handle of a default + * component interface + * @param[out] p_allocator - on return, points to a handle of a private + * instance allocation interface + * @param pool - a memory pool with the component lifetime + * + * @return APR_SUCCESS if successful, otherwise a non-zero error + * code */ typedef int (*OpenComponentInitializer) (OpenComponentHandle* p_component, Index: vm/include/open/vm_kernel_classes.h =================================================================== --- vm/include/open/vm_kernel_classes.h (revision 487512) +++ vm/include/open/vm_kernel_classes.h (working copy) @@ -14,10 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Euguene Ostrovsky - * @version $Revision: 1.1.2.1.4.4 $ - */ + #ifndef _VM_KERNEL_CLASSES_H_ #define _VM_KERNEL_CLASSES_H_ Index: vm/include/slot.h =================================================================== --- vm/include/slot.h (revision 487512) +++ vm/include/slot.h (working copy) @@ -13,10 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Salikh Zakirov - * @version $Revision$ - */ + #ifndef _SLOT_H_ #define _SLOT_H_ @@ -32,19 +29,24 @@ #include "environment.h" // Global_Env // (this file is based on gc_v4/src/compressed_references.h) -// -// The Slot data structure represents a pointer to a heap location that contains -// a reference field. It is packaged this way because the heap location may -// contain either a raw pointer or a compressed pointer, depending on command line -// options. -// -// Code originally of the form: -// ManagedObject **p_slot = foo ; -// ... *p_slot ... -// can be expressed as: -// Slot p_slot(foo); -// ... p_slot.dereference() ... +/** + * The Slot data structure represents a pointer to a heap location that contains + * a reference field. It is packaged this way because the heap location may + * contain either a raw pointer or a compressed pointer, depending on command line + * options. + * + * Code originally of the form: + *
+ * ManagedObject **p_slot = foo ;
+ *     ... *p_slot ...
+ * 
+ * can be expressed as: + *
+ * Slot p_slot(foo);
+ *     ... p_slot.dereference() ...
+ * 
+ */ class Slot { private: union { @@ -67,16 +69,22 @@ heap_ceiling = ceiling; } - // Sets the raw value of the slot. + /** + * Sets the raw value of the slot. + */ void *set_address(void *v) { content.value = v; return v; } - // Returns the raw pointer value. + /** + * @return The raw pointer value. + */ void *get_address() { return content.value; } - // Dereferences the slot and converts it to a raw object pointer. + /** + * Dereferences the slot and converts it to a raw object pointer. + */ void *dereference() { if (VM_Global_State::loader_env->compress_references) { assert(content.compressed != NULL); @@ -87,7 +95,9 @@ } } - // Writes a new object reference into the slot. + /** + * Writes a new object reference into the slot. + */ void write(void *obj) { if (VM_Global_State::loader_env->compress_references) { if (obj != NULL) { @@ -100,7 +110,9 @@ } } - // Returns true if the slot points to a null reference. + /** + * @return TRUE if the slot points to a null reference. + */ bool is_null() { if (VM_Global_State::loader_env->compress_references) { assert(content.compressed != NULL); @@ -111,8 +123,10 @@ } } - // Returns the raw value of a managed null, which may be different - // depending on whether compressed references are used. + /** + * @return The raw value of a managed null, which may be different + * depending on whether compressed references are used. + */ static void *managed_null() { return (VM_Global_State::loader_env->compress_references ? heap_base : NULL); } Index: vm/vmcore/include/Class.h =================================================================== --- vm/vmcore/include/Class.h (revision 487512) +++ vm/vmcore/include/Class.h (working copy) @@ -15,10 +15,6 @@ * limitations under the License. */ -/** - * @author Pavel Pervov - * @version $Revision: 1.1.2.7.2.1.2.5 $ - */ #ifndef _CLASS_H_ #define _CLASS_H_ /** @@ -52,62 +48,97 @@ struct AnnotationTable; -/** The constant pool entry descriptor. -* For each constant pool entry, the descriptor content varies depending -* on the constant pool tag that corresponds to this constant pool entry. -* Content of each entry is described in -* -* The Java Virtual Machine Specification, Chapter 4, The Constant -* Pool section, with the following exceptions:
    -*
  1. A zero entry of the constant pool contains an array of tags -* corresponding to entries in the constant pool entries array.
  2. -*
  3. As required by -* -* The Java Virtual Machine Specification, Chapter 5 -* Linking/Resolution section, errors are cached for entries that have -* not been resolved earlier for some reason.
-*/ +/** + * The constant pool entry descriptor. + * For each constant pool entry, the descriptor content varies depending + * on the constant pool tag that corresponds to this constant pool entry. + * Content of each entry is described in + * + * The Java Virtual Machine Specification, Chapter 4, The Constant + * Pool section, with the following exceptions:
    + *
  1. A zero entry of the constant pool contains an array of tags + * corresponding to entries in the constant pool entries array.
  2. + *
  3. As required by + * + * The Java Virtual Machine Specification, Chapter 5 + * Linking/Resolution section, errors are cached for entries that have + * not been resolved earlier for some reason.
+ */ union ConstPoolEntry { - /** Zero entry of constant pool only: array of tags for constant pool.*/ +/** + * Zero entry of constant pool only: array of tags for constant pool. + */ unsigned char* tags; - /** CONSTANT_Class.*/ + /** + * CONSTANT_Class. + */ struct { union { - /** Resolved class*/ +/** + * Resolved class + */ Class* klass; - /** Resolution error, if any.*/ +/** + * Resolution error, if any. + */ struct { - /** Next resolution error in this constant pool.*/ + /** + * Next resolution error in this constant pool. + */ ConstPoolEntry* next; - /** Exception object describing an error.*/ +/** + * Exception object describing an error. + */ ManagedObject* cause; } error; }; - /** Index to class name in this constant pool.*/ + /** + * Index to class name in this constant pool. + */ uint16 name_index; } CONSTANT_Class; - /** CONSTANT_String.*/ + /** + * CONSTANT_String. + */ struct { - /** Resolved class.*/ + /** + * Resolved class. + */ String* string; - /** Index of CONSTANT_Utf8 for this string.*/ + /** + * Index of CONSTANT_Utf8 for this string. + */ uint16 string_index; } CONSTANT_String; - /** CONSTANT_{Field|Method|InterfaceMethod}ref.*/ + /** + * CONSTANT_{Field|Method|InterfaceMethod}ref. + */ struct { union { - /** Generic class member for CONSTANT_*ref. - * Only valid for resolved refs.*/ + /** + * Generic class member for CONSTANT_*ref. + * Only valid for resolved refs. + */ Class_Member* member; - /** Resolved entry for CONSTANT_Fieldref.*/ + /** + * Resolved entry for CONSTANT_Fieldref. + */ Field* field; - /** resolved entry for CONSTANT_[Interface]Methodref.*/ + /** + * Resolved entry for CONSTANT_[Interface]Methodref. + */ Method* method; - /** Resolution error, if any.*/ + /** + * Resolution error, if any. + */ struct { - /** Next resolution error in this constant pool.*/ + /** + * Next resolution error in this constant pool. + */ ConstPoolEntry* next; - /** Exception object describing error.*/ + /** + * Exception object describing error. + */ ManagedObject* cause; } error; }; @@ -117,54 +148,86 @@ uint16 name_and_type_index; } CONSTANT_ref; - /** Shortcut to resolution error in CONSTANT_Class and CONSTANT_ref.*/ + /** + * Shortcut to resolution error in CONSTANT_Class and CONSTANT_ref. + */ struct { - /** Next resolution error in this constant pool.*/ + /** + * Next resolution error in this constant pool. + */ ConstPoolEntry* next; - /** Exception object describing error.*/ + /** + * Exception object describing error. + */ ManagedObject* cause; } error; - /** CONSTANT_Integer.*/ + /** + * CONSTANT_Integer. + */ uint32 int_value; - /** CONSTANT_Float.*/ + /** + * CONSTANT_Float. + */ float float_value; - /** CONSTANT_Long and CONSTANT_Double. - * @note In this case we pack all 8 bytes of long/double in one - * ConstPoolEntry and leave the second ConstPoolEntry of the long/double - * unused.*/ + /** + * CONSTANT_Long and CONSTANT_Double. + * + * @note In this case we pack all 8 bytes of long/double in one + * ConstPoolEntry and leave the second + * ConstPoolEntry of the long/double unused. + */ struct { uint32 low_bytes; uint32 high_bytes; } CONSTANT_8byte; - /** CONSTANT_NameAndType.*/ + /** + * CONSTANT_NameAndType. + */ struct { - /** Resolved name.*/ + /** + * Resolved name. + */ String* name; - /** Resolved descriptor.*/ + /** + * Resolved descriptor. + */ String* descriptor; - /** Name index in this constant pool.*/ + /** + * Name index in this constant pool. + */ uint16 name_index; - /** Descriptor index in this constant pool.*/ + /** + * Descriptor index in this constant pool. + */ uint16 descriptor_index; } CONSTANT_NameAndType; - /** CONSTANT_Utf8.*/ + /** + * CONSTANT_Utf8. + */ struct { - /** Content of CONSTANT_Utf8 entry.*/ + /** + * Content of CONSTANT_Utf8 entry. + */ String* string; } CONSTANT_Utf8; }; - - -/** Types of constant pool entries. These entry types are defined by a seperate -* byte array that the first constant pool entry points at.*/ + /** + * Types of constant pool entries. These entry types are defined by a seperate + * byte array that the first constant pool entry points at. + */ enum ConstPoolTags { - /** pointer to the tags array.*/ + /** + * Pointer to the tags array. + */ CONSTANT_Tags = 0, - /** The rest of tag values are taken from + + /** + * The rest of tag values are taken from * * The Java Virtual Machine Specification, Chapter 4, The Constant - * Pool section.*/ + * Pool section. + */ CONSTANT_Utf8 = 1, CONSTANT_Integer = 3, CONSTANT_Float = 4, @@ -179,9 +242,11 @@ }; -/** The constant pool of a class and related operations. +/** + * 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.*/ + * on the constant pool, such as parsing and processing queries. + */ struct ConstantPool { private: @@ -202,73 +267,106 @@ ConstPoolEntry* m_failedResolution; public: - /** Initializes the constant pool to its initial values.*/ + /** + * Initializes the constant pool to its initial values. + */ ConstantPool() { init(); } - /** Clears constant pool content (if there are any).*/ + /** + * Clears constant pool content (if there are any). + */ ~ConstantPool() { clear(); } - /** Checks whether the constant pool is not empty. - * @return true if the constant pool contains - * certain entries; otherwise false.*/ + /** + * Checks whether the constant pool is not empty. + * + * @return TRUE if the constant pool contains + * certain entries; otherwise FALSE.*/ bool available() const { return m_size != 0; } - /** Gets the size of the given constant pool. - * @return The number of entries in the constant pool.*/ + /** + * Gets the size of the given constant pool. + * + * @return The number of entries in the constant pool. + */ uint16 get_size() const { return m_size; } - /** Checks whether the index is a valid one in the constant pool. + /** + * Checks whether the index is a valid one in the constant pool. + * * @param[in] index - an index in the constant pool - * @return true if the index is a valid one in the constant - * pool; otherwise false.*/ + * + * @return TRUE if the index is a valid one in the constant + * pool; otherwise FALSE. + */ bool is_valid_index(uint16 index) const { // index is valid if it's greater than zero and less than m_size // See specification 4.2 about constant_pool_count return index != 0 && index < m_size; } - /** Checks whether the constant-pool entry is resolved. + /** + * Checks whether the constant-pool entry is resolved. + * * @param[in] index - an index in the constant pool - * @return true if the entry is resolved; - * otherwise false.*/ + * + * @return TRUE if the entry is resolved; + * otherwise FALSE. + */ bool is_entry_resolved(uint16 index) const { assert(is_valid_index(index)); return (m_entries[0].tags[index] & RESOLVED_MASK) != 0; } - /** Checks whether the resolution of the constant-pool entry has failed. + /** + * Checks whether the resolution of the constant-pool entry has failed. + * * @param[in] index - an index in the constant pool - * @return true if the resolution error is recorded - * for the entry.*/ + * + * @return TRUE if the resolution error is recorded + * for the entry. + */ bool is_entry_in_error(uint16 index) const { assert(is_valid_index(index)); return (m_entries[0].tags[index] & ERROR_MASK) != 0; } - /** Checks whether the constant-pool entry represents the string of - * the #CONSTANT_Utf8 type. - * @param[in] index - an index in the constant pool - * @return true if the given entry is the utf8 - * string; otherwise false.*/ + /** + * Checks whether the constant-pool entry represents the string of + * the #CONSTANT_Utf8 type. + * + * @param[in] index - an index in the constant pool + * + * @return TRUE if the given entry is the utf8 + * string; otherwise FALSE. + */ bool is_utf8(uint16 index) const { return get_tag(index) == CONSTANT_Utf8; } - /** Checks whether the constant-pool entry refers to a #CONSTANT_Class. + /** + * Checks whether the constant-pool entry refers to a #CONSTANT_Class. + * * @param[in] index - an index in the constant pool - * @return true if the given entry is a class; - * otherwise false.*/ + * + * @return TRUE if the given entry is a class; + * otherwise FALSE. + */ bool is_class(uint16 index) const { return get_tag(index) == CONSTANT_Class; } - /** Checks whether the constant-pool entry contains a constant. + /** + * Checks whether the constant-pool entry contains a constant. + * * @param[in] index - an index in the constant pool - * @return true if the given entry contains a constant; - * otherwise false.*/ + * + * @return TRUE if the given entry contains a constant; + * otherwise FALSE. + */ bool is_constant(uint16 index) const { return get_tag(index) == CONSTANT_Integer || get_tag(index) == CONSTANT_Float @@ -278,116 +376,166 @@ || get_tag(index) == CONSTANT_Class; } - /** Checks whether the constant-pool entry is a literal constant. + /** + * Checks whether the constant-pool entry is a literal constant. + * * @param[in] index - an index in the constant pool - * @return true if the given entry contains a string; - * otherwise false.*/ + * + * @return TRUE if the given entry contains a string; + * otherwise FALSE. + */ bool is_string(uint16 index) const { return get_tag(index) == CONSTANT_String; } - /** Checks whether the constant-pool entry is #CONSTANT_NameAndType. + /** + * Checks whether the constant-pool entry is #CONSTANT_NameAndType. + * * @param[in] index - an index in the constant pool - * @return true if the given entry contains name-and-type; - * otherwise false.*/ + * + * @return TRUE if the given entry contains name-and-type; + * otherwise FALSE. + */ bool is_name_and_type(uint16 index) const { return get_tag(index) == CONSTANT_NameAndType; } - /** Checks whether the constant-pool entry contains a field reference, - * #CONSTANT_Fieldref. + /** + * Checks whether the constant-pool entry contains a field reference, + * #CONSTANT_Fieldref. + * * @param[in] index - an index in the constant pool - * @return true if the given entry contains a field reference; - * otherwise false.*/ + * + * @return TRUE if the given entry contains a field reference; + * otherwise FALSE. + */ bool is_fieldref(uint16 index) const { return get_tag(index) == CONSTANT_Fieldref; } - /** Checks whether the constant-pool entry contains a method reference, - * #CONSTANT_Methodref. + /** + * Checks whether the constant-pool entry contains a method reference, + * #CONSTANT_Methodref. + * * @param[in] index - an index in the constant pool - * @return true if the given entry contains a method reference; - * otherwise false.*/ + * + * @return TRUE if the given entry contains a method reference; + * otherwise FALSE. + */ bool is_methodref(uint16 index) const { return get_tag(index) == CONSTANT_Methodref; } - /** Checks whether the constant-pool entry constains an interface-method + /** + * Checks whether the constant-pool entry constains an interface-method * reference, #CONSTANT_InterfaceMethodref. * @param[in] index - an index in the constant pool - * @return true if the given entry contains an interface-method - * reference; otherwise false.*/ + * @return TRUE if the given entry contains an interface-method + * reference; otherwise FALSE. + */ bool is_interfacemethodref(uint16 index) const { return get_tag(index) == CONSTANT_InterfaceMethodref; } - /** Gets a tag of the referenced constant-pool entry. + /** + * Gets a tag of the referenced constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return A constant-pool entry tag for a given index.*/ + * + * @return A constant-pool entry tag for a given index. + */ unsigned char get_tag(uint16 index) const { assert(is_valid_index(index)); return m_entries[0].tags[index] & TAG_MASK; } - /** Gets characters from the utf8 string stored in the + /** + * Gets characters from the utf8 string stored in the * constant pool. + * * @param[in] index - an index in the constant pool + * * @return Characters from the utf8 string stored in - * the constant pool.*/ + * the constant pool. + */ const char* get_utf8_chars(uint16 index) const { return get_utf8_string(index)->bytes; } - /** Gets the utf8 string stored in the constant pool. + /** + * Gets the utf8 string stored in the constant pool. + * * @param[in] index - an index in the constant pool - * @return The utf8 string.*/ + * + * @return The utf8 string. + */ String* get_utf8_string(uint16 index) const { assert(is_utf8(index)); return m_entries[index].CONSTANT_Utf8.string; } - /** Gets characters stored in the utf8 string for - * the #CONSTANT_String entry. + /** + * Gets characters stored in the utf8 string for + * the #CONSTANT_String entry. + * * @param[in] index - an index in the constant pool + * * @return The utf8 string characters for the given - * constant-pool entry.*/ + * constant-pool entry. + */ const char* get_string_chars(uint16 index) const { return get_string(index)->bytes; } - /** Gets the utf8 string stored for the #CONSTANT_String + /** + * Gets the utf8 string stored for the #CONSTANT_String * entry. + * * @param[in] index - an index in the constant pool - * @return The utf8 string stored in the constant-pool entry.*/ + * + * @return The utf8 string stored in the constant-pool entry. + */ String* get_string(uint16 index) const { assert(is_string(index)); return m_entries[index].CONSTANT_String.string; } - /** Gets the utf8 string representing the name part of the + /** + * Gets the utf8 string representing the name part of the * name-and-type constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return The utf8 string with the name part.*/ + * + * @return The utf8 string with the name part. + */ String* get_name_and_type_name(uint16 index) const { assert(is_name_and_type(index)); assert(is_entry_resolved(index)); return m_entries[index].CONSTANT_NameAndType.name; } - /** Gets the utf8 string representing the descriptor part of + /** + * Gets the utf8 string representing the descriptor part of * the name-and-type constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return The utf8 string with the descriptor part.*/ + * + * @return The utf8 string with the descriptor part. + */ String* get_name_and_type_descriptor(uint16 index) const { assert(is_name_and_type(index)); assert(is_entry_resolved(index)); return m_entries[index].CONSTANT_NameAndType.descriptor; } - /** Gets the generic class member for the CONSTANT_*ref + /** + * Gets the generic class member for the CONSTANT_*ref * constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return The generic-class member for the given constant-pool entry.*/ + * + * @return The generic-class member for the given constant-pool entry. + */ Class_Member* get_ref_class_member(uint16 index) const { assert(is_fieldref(index) || is_methodref(index) @@ -395,10 +543,14 @@ return m_entries[index].CONSTANT_ref.member; } - /** Gets the method from the #CONSTANT_Methodref or - * the #CONSTANT_InterfaceMethodref constant-pool entry + /** + * Gets the method from the #CONSTANT_Methodref or + * the #CONSTANT_InterfaceMethodref constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return The method from the given constant-pool entry.*/ + * + * @return The method from the given constant-pool entry. + */ Method* get_ref_method(uint16 index) const { assert(is_methodref(index) || is_interfacemethodref(index)); @@ -406,134 +558,189 @@ return m_entries[index].CONSTANT_ref.method; } - /** Gets the field from the #CONSTANT_Fieldref + /** + * Gets the field from the #CONSTANT_Fieldref * constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return The field from the given constant-pool entry.*/ + * + * @return The field from the given constant-pool entry. + */ Field* get_ref_field(uint16 index) const { assert(is_fieldref(index)); assert(is_entry_resolved(index)); return m_entries[index].CONSTANT_ref.field; } - /** Gets the class for the #CONSTANT_Class + /** + * Gets the class for the #CONSTANT_Class * constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return The class for the given constant-pool entry.*/ + * + * @return The class for the given constant-pool entry. + */ Class* get_class_class(uint16 index) const { assert(is_class(index)); assert(is_entry_resolved(index)); return m_entries[index].CONSTANT_Class.klass; } - /** Gets a 32-bit value (either interger or float) for a constant stored + /** + * Gets a 32-bit value (either interger or float) for a constant stored * in the constant pool. + * * @param[in] index - an index in the constant pool - * @return The value of a 32-bit constant stored in the constant pool.*/ + * + * @return The value of a 32-bit constant stored in the constant pool. + */ uint32 get_4byte(uint16 index) const { assert(get_tag(index) == CONSTANT_Integer || get_tag(index) == CONSTANT_Float); return m_entries[index].int_value; } - /** Gets an integer value for a constant stored in the constant pool. + /** + * Gets an integer value for a constant stored in the constant pool. + * * @param[in] index - an index in the constant pool - * @return The value of integer constant stored in the constant pool.*/ + * + * @return The value of integer constant stored in the constant pool. + */ uint32 get_int(uint16 index) const { assert(get_tag(index) == CONSTANT_Integer); return m_entries[index].int_value; } - /** Gets a float value for a constant stored in the constant pool. + /** + * Gets a float value for a constant stored in the constant pool. + * * @param[in] index - an index in the constant pool - * @return A value of a float constant stored in the constant pool.*/ + * + * @return A value of a float constant stored in the constant pool. + */ float get_float(uint16 index) const { assert(get_tag(index) == CONSTANT_Float); return m_entries[index].float_value; } - /** Gets a low word of the 64-bit constant (either long or double) + /** + * Gets a low word of the 64-bit constant (either long or double) * stored in the constant pool. + * * @param[in] index - an index in the constant pool - * @return A value of low 32-bits of 64-bit constant.*/ + * + * @return A value of low 32-bits of 64-bit constant. + */ uint32 get_8byte_low_word(uint16 index) const { assert(get_tag(index) == CONSTANT_Long || get_tag(index) == CONSTANT_Double); return m_entries[index].CONSTANT_8byte.low_bytes; } - /** Gets a high word of the 64-bit constant (either long or double) + /** + * Gets a high word of the 64-bit constant (either long or double) * stored in the constant pool. + * * @param[in] index - an index in the constant pool - * @return A value of high 32-bits of 64-bit constant.*/ + * + * @return A value of high 32-bits of 64-bit constant. + */ uint32 get_8byte_high_word(uint16 index) const { assert(get_tag(index) == CONSTANT_Long || get_tag(index) == CONSTANT_Double); return m_entries[index].CONSTANT_8byte.high_bytes; } - /** Gets an address of a constant stored in the constant pool. + /** + * Gets an address of a constant stored in the constant pool. + * * @param[in] index - an index in the constant pool - * @return An address of a constant.*/ + * + * @return An address of a constant. + */ void* get_address_of_constant(uint16 index) const { assert(is_constant(index)); assert(!is_string(index)); return (void*)(m_entries + index); } - /** Gets an exception, which has caused failure of the referred + /** + * Gets an exception, which has caused failure of the referred * constant-pool entry. + * * @param[in] index - an index in the constant pool + * * @return An exception object, which is the cause of the - * resolution failure.*/ + * resolution failure. + */ jthrowable get_error_cause(uint16 index) const { assert(is_entry_in_error(index)); return (jthrowable)(&(m_entries[index].error.cause)); } - /** Gets a head of a single-linked list containing resolution errors + /** + * Gets a head of a single-linked list containing resolution errors * in the given constant pool. + * * @return A head of a signle-linked list of constant-pool entries, - * which resolution had failed.*/ + * which resolution had failed. + */ ConstPoolEntry* get_error_chain() const { return m_failedResolution; } - /** Gets an an index in the constant pool where the utf8 - * representation for #CONSTANT_String is stored. + /** + * Gets an an index in the constant pool where the utf8 + * representation for #CONSTANT_String is stored. + * * @param[in] index - an index in the constant pool for the - * #CONSTANT_String entry + * #CONSTANT_String entry + * * @return An an index in the constant pool with the utf8 - * representation of the given string.*/ + * representation of the given string. + */ uint16 get_string_index(uint16 index) const { assert(is_string(index)); return m_entries[index].CONSTANT_String.string_index; } - /** Gets an index of the constant-pool entry containing the + /** + * Gets an index of the constant-pool entry containing the * utf8 string with the name part. + * * @param[in] index - an index in the constant pool + * * @return An an index in the constant pool with the utf8 - * name string.*/ + * name string. + */ uint16 get_name_and_type_name_index(uint16 index) const { assert(is_name_and_type(index)); return m_entries[index].CONSTANT_NameAndType.name_index; } - /** Gets an index of the constant-pool entry containing the + /** + * Gets an index of the constant-pool entry containing the * utf8 string with the descriptor part. + * * @param[in] index - an index in the constant pool + * * @return An an index in the constant pool with the utf8 - * string for the descriptor.*/ + * string for the descriptor. + */ uint16 get_name_and_type_descriptor_index(uint16 index) const { assert(is_name_and_type(index)); return m_entries[index].CONSTANT_NameAndType.descriptor_index; } - /** Gets an index of the constant-pool entry containing a class for + /** + * Gets an index of the constant-pool entry containing a class for * the given CONSTANT_*ref entry. + * * @param[in] index - an index in the constant pool - * @return An index of a class entry for the given constant-pool entry.*/ + * + * @return An index of a class entry for the given constant-pool entry. + */ uint16 get_ref_class_index(uint16 index) const { assert(is_fieldref(index) || is_methodref(index) @@ -541,11 +748,15 @@ return m_entries[index].CONSTANT_ref.class_index; } - /** Gets an index of CONSTANT_NameAndType for the given + /** + * Gets an index of CONSTANT_NameAndType for the given * constant-pool entry. + * * @param[in] index - an index in the constant pool - * @return An index of #CONSTANT_NameAndType for the given - * constant-pool entry.*/ + * + * @return An index of #CONSTANT_NameAndType for the given + * constant-pool entry. + */ uint16 get_ref_name_and_type_index(uint16 index) const { assert(is_fieldref(index) || is_methodref(index) @@ -553,18 +764,26 @@ return m_entries[index].CONSTANT_ref.name_and_type_index; } - /** Gets a class-name an index in the constant pool for the - * #CONSTANT_Class entry. + /** + * Gets a class-name an index in the constant pool for the + * #CONSTANT_Class entry. + * * @param[in] index - an index in the constant pool - * @return An index of the utf8 name of the given class.*/ + * + * @return An index of the utf8 name of the given class. + */ uint16 get_class_name_index(uint16 index) const { assert(is_class(index)); return m_entries[index].CONSTANT_Class.name_index; } - /** Resolves an entry to the class. + /** + * Resolves an entry to the class. + * * @param[in] index - an index in the constant pool - * @param[in] clss - a class to resolve the given entry to*/ + * + * @param[in] clss - a class to resolve the given entry to + */ void resolve_entry(uint16 index, Class* clss) { // we do not want to resolve entry of a different type assert(is_class(index)); @@ -572,9 +791,13 @@ m_entries[index].CONSTANT_Class.klass = clss; } - /** Resolves an entry to the field. + /** + * Resolves an entry to the field. + * * @param[in] index - an index in the constant pool - * @param[in] field - a field to resolve the given entry to*/ + * + * @param[in] field - a field to resolve the given entry to + */ void resolve_entry(uint16 index, Field* field) { // we do not want to resolve entry of different type assert(is_fieldref(index)); @@ -582,9 +805,12 @@ m_entries[index].CONSTANT_ref.field = field; } - /** Resolves an entry to the method. + /** + * Resolves an entry to the method. + * * @param[in] index - an index in the constant pool - * @param[in] method - a method to resolve the given entry to*/ + * @param[in] method - a method to resolve the given entry to + */ void resolve_entry(uint16 index, Method* method) { // we do not want to resolve entry of a different type assert(is_methodref(index) || is_interfacemethodref(index)); @@ -592,10 +818,14 @@ m_entries[index].CONSTANT_ref.method = method; } - /** Records a resolution error into a constant-pool entry. + /** + * Records a resolution error into a constant-pool entry. + * * @param[in] index - an index in the constant pool * @param[in] exn - a cause of resolution failure - * @note Disable suspension during this operation.*/ + * + * @note Disable suspension during this operation. + */ void resolve_as_error(uint16 index, jthrowable exn) { assert(is_class(index) || is_fieldref(index) @@ -608,29 +838,41 @@ m_failedResolution = &(m_entries[index]); } - /** Parses in a constant pool for a class. + /** + * Parses in a constant pool for a class. + * * @param[in] clss - a class containing the given constant pool * @param[in] string_pool - a reference to the string pool to intern strings in * @param[in] cfs - a byte stream to parse the constant pool from - * @return true if the constant pool was parsed successfully; - * false if some error was discovered during the parsing.*/ + * + * @return TRUE if the constant pool was parsed successfully; + * FALSE if some error was discovered during the parsing. + */ bool parse(Class* clss, String_Pool& string_pool, ByteReader& cfs); - /** Checks constant pool consistency. + * * @param[in] clss - the class that the given constant pool belongs to - * @return true if the constant pool of clss is valid; - * otherwise false.*/ + * + * @return TRUE if the constant pool of clss is valid; + * otherwise FALSE. + */ bool check(Global_Env *, Class* clss); - /** Clears the constant-pool content: tags and entries arrays.*/ + /** + * Clears the constant-pool content: tags and entries arrays. + */ void clear() { if(m_size != 0) { delete[] m_entries[0].tags; @@ -639,15 +881,20 @@ init(); } - /** Initializes the constant pool to initial values.*/ + /** + * Initializes the constant pool to initial values. + */ void init() { m_size = 0; m_entries = NULL; m_failedResolution = NULL; } private: - /** Sets a resolved flag in the constant-pool entry. - * @param[in] index - an index in the constant pool*/ + /** + * Sets a resolved flag in the constant-pool entry. + * + * @param[in] index - an index in the constant pool + */ void set_entry_resolved(uint16 index) { assert(is_valid_index(index)); //// we do not want to resolve one entry twice @@ -660,8 +907,11 @@ m_entries[0].tags[index] |= RESOLVED_MASK; } - /** Sets an error flag in the constant-pool entry to mark it as failed. - * @param[in] index - an index in the constant pool*/ + /** + * Sets an error flag in the constant-pool entry to mark it as failed. + * + * @param[in] index - an index in the constant pool + */ void set_entry_error_state(uint16 index) { assert(is_valid_index(index)); //// we do not want to reset the resolved error @@ -674,11 +924,14 @@ m_entries[0].tags[index] |= ERROR_MASK; } - /** Resolves the #CONSTANT_NameAndType constant-pool entry + /** + * Resolves the #CONSTANT_NameAndType constant-pool entry * to actual string values. + * * @param[in] index - an index in the constant pool * @param[in] name - name-and-type name - * @param[in] descriptor - name-and-type type (descriptor)*/ + * @param[in] descriptor - name-and-type type (descriptor) + */ void resolve_entry(uint16 index, String* name, String* descriptor) { // we do not want to resolve entry of different type assert(is_name_and_type(index)); @@ -687,10 +940,13 @@ m_entries[index].CONSTANT_NameAndType.descriptor = descriptor; } - /** Resolves the CONSTANT_String constant-pool entry to + /** + * Resolves the CONSTANT_String constant-pool entry to * actual string values. + * * @param[in] index - an index in the constant pool - * @param[in] str - an actual string*/ + * @param[in] str - an actual string + */ void resolve_entry(uint16 index, String* str) { assert(is_string(index)); set_entry_resolved(index); @@ -699,15 +955,21 @@ }; -/** Converts a class name from an internal (VM) form to the Java form. +/** + * Converts a class name from an internal (VM) form to the Java form. + * * @param[in] class_name - the class name in an internal form - * @return The class name in the Java form.*/ + * + * @return The class name in the Java form. + */ String* class_name_get_java_name(const String* class_name); // A Java class extern "C" { -/** The state of the Java class*/ +/** + * The state of the Java class + */ enum Class_State { ST_Start, /// the initial state @@ -723,50 +985,90 @@ }; -/** Access and properties flags for Class, Field and Method.*/ +/** + * Access and properties flags for Class, Field and Method. + */ enum AccessAndPropertiesFlags { - /** Public access modifier. Valid for Class, Field, Method. */ +/** + * Public access modifier. Valid for Class, Field, Method. + */ ACC_PUBLIC = 0x0001, - /** Private access modifier. Valid for Field, Method.*/ +/** + *Private access modifier. Valid for Field, Method. + */ ACC_PRIVATE = 0x0002, - /** Protected access modifier. Valid for Field, Method.*/ +/** + * Protected access modifier. Valid for Field, Method. + */ ACC_PROTECTED = 0x0004, - /** Static modifier. Valid for Field, Method.*/ + /** + * Static modifier. Valid for Field, Method. + */ ACC_STATIC = 0x0008, - /** Final modifier. Valid for Class, Field, Method.*/ + /** + * Final modifier. Valid for Class, Field, Method. + */ ACC_FINAL = 0x0010, - /** Super modifier. Valid for Class.*/ + /** + * Super modifier. Valid for Class. + */ ACC_SUPER = 0x0020, - /** Synchronized modifier. Valid for Method.*/ + /** + * Synchronized modifier. Valid for Method. + */ ACC_SYNCHRONIZED = 0x0020, - /** Bridge modifier. Valid for Method (since J2SE 5.0).*/ + /** + * Bridge modifier. Valid for Method (since J2SE 5.0). + */ ACC_BRIDGE = 0x0040, - /** Volatile modifier. Valid for Field.*/ + /** + * Volatile modifier. Valid for Field. + */ ACC_VOLATILE = 0x0040, - /** Varargs modifier. Valid for Method (since J2SE 5.0).*/ + /** + * Varargs modifier. Valid for Method (since J2SE 5.0). + */ ACC_VARARGS = 0x0080, - /** Transient modifier. Valid for Field.*/ + /** + * Transient modifier. Valid for Field. + */ ACC_TRANSIENT = 0x0080, - /** Native modifier. Valid for Method.*/ + /** + * Native modifier. Valid for Method. + */ ACC_NATIVE = 0x0100, - /** Interface modifier. Valid for Class.*/ + /** + * Interface modifier. Valid for Class. + */ ACC_INTERFACE = 0x0200, - /** Abstract modifier. Valid for Class, Method.*/ + /** + * Abstract modifier. Valid for Class, Method. + */ ACC_ABSTRACT = 0x0400, - /** Strict modifier. Valid for Method.*/ + /** + * Strict modifier. Valid for Method. + */ ACC_STRICT = 0x0800, - /** Synthetic modifier. Valid for Class, Field, Method (since J2SE 5.0).*/ + /** + * Synthetic modifier. Valid for Class, Field, Method (since J2SE 5.0). + */ ACC_SYNTHETIC = 0x1000, - /** Annotation modifier. Valid for Class (since J2SE 5.0).*/ + /** + * Annotation modifier. Valid for Class (since J2SE 5.0). + */ ACC_ANNOTATION = 0x2000, - /** Enum modifier. Valid for Class, Field (since J2SE 5.0).*/ + /** + * Enum modifier. Valid for Class, Field (since J2SE 5.0). + */ ACC_ENUM = 0x4000 }; -/** VM representation of Java class. +/** + * VM representation of Java class. * This class contains methods for parsing classes, querying class properties, * setting external properties of a class (source file name, class file name), - * calling the verifier, preparing, resolving and initializing the class.*/ + * calling the verifier, preparing, resolving and initializing the class. + */ struct Class { private: @@ -1047,57 +1349,83 @@ uint32 m_num_field_padding_bytes; public: - /** Initializes class-member variables to their initial values. + /** + * Initializes class-member variables to their initial values. + * * @param[in] env - VM environment * @param[in] name - a class name to assign to the given class - * @param[in] cl - a class loader for the given class*/ + * @param[in] cl - a class loader for the given class + */ void init_internals(const Global_Env* env, const String* name, ClassLoader* cl); - /** Clears member variables within a class.*/ + /** + * Clears member variables within a class. + */ void clear_internals(); - /** Determines whether the given class has a super class. - * @return true if the current class has a super class; - * otherwise false.*/ + /** + * Determines whether the given class has a super class. + * + * @return TRUE if the current class has a super class; + * otherwise FALSE. + */ bool has_super_class() const { return m_super_class.clss != NULL; } - /** Gets the name of the super class. + /** + * Gets the name of the super class. * * @return The super class name or NULL, if the given class * is java/lang/Object. + * * @note It is valid until the super class is loaded; after that, use * get_super_class()->get_name() to retrieve the - * super class name.*/ + * super class name. + */ const String* get_super_class_name() const { return m_super_class.name; } - /** Gets the super class of the given class. + /** + * Gets the super class of the given class. + * * @return The super class of the given class or NULL, - * if the given class is java/lang/Object.*/ + * if the given class is java/lang/Object. + */ Class* get_super_class() const { return m_super_class.clss; } - /** Gets the class loader of the given class. - * @return the class loader of the given class.*/ + /** + * Gets the class loader of the given class. + * + * @return The class loader of the given class. + */ ClassLoader* get_class_loader() const { return m_class_loader; } - /** Gets the class handle of java.lang.Class for the given class. - * @return The java.lang.Class handle for the given class.*/ + /** + * Gets the class handle of java.lang.Class for the given class. + * + * @return The java.lang.Class handle for the given class. + */ ManagedObject** get_class_handle() const { return m_class_handle; } - /** Gets the natively interned class name for the given class. - * @return The class name in the VM format.*/ + /** + * Gets the natively interned class name for the given class. + * + * @return The class name in the VM format. + */ const String* get_name() const { return m_name; } - /** Gets a natively interned class name for the given class. - * @return A class name in the Java format.*/ + /** + * Gets a natively interned class name for the given class. + * + * @return A class name in the Java format. + */ String* get_java_name() { if(!m_java_name) { m_java_name = class_name_get_java_name(m_name); @@ -1105,381 +1433,591 @@ return m_java_name; } - /** Gets a class signature. - * @return A class signature.*/ + /** + * Gets a class signature. + * + * @return A class signature. + */ String* get_signature() const { return m_signature; } - /** Gets a simple name of the class. - * @return A simple name of the class.*/ + /** + * Gets a simple name of the class. + * + * @return A simple name of the class. + */ String* get_simple_name(); - /** Gets a package containing the given class. - * @return A package to which the given class belongs.*/ + /** + * Gets a package containing the given class. + * + * @return A package to which the given class belongs. + */ Package* get_package() const { return m_package; } - /** Gets depth in the hierarchy of the given class. - * @return A number of classes in the super-class hierarchy.*/ + /** + * Gets depth in the hierarchy of the given class. + * + * @return A number of classes in the super-class hierarchy. + */ int get_depth() const { return m_depth; } bool get_fast_instanceof_flag() const { return m_is_suitable_for_fast_instanceof; } - /** Gets the vtable for the given class. + /** + * Gets the vtable for the given class. + * * @return The vtable for the given class or NULL, if the given - * class is an interface.*/ + * class is an interface. + */ VTable* get_vtable() const { return m_vtable; } - /** Gets an allocation handle for the given class.*/ + /** + * Gets an allocation handle for the given class. + */ Allocation_Handle get_allocation_handle() const { return m_allocation_handle; } - /** Gets the length of the source-file name. - * @return The length in bytes of the source-file name.*/ + /** + * Gets the length of the source-file name. + * + * @return The length in bytes of the source-file name. + */ size_t get_source_file_name_length() { assert(has_source_information()); return m_src_file_name->len; } - /** Gets a source-file name. - * @return A source-file name for the given class.*/ + /** + * Gets a source-file name. + * + * @return A source-file name for the given class. + */ const char* get_source_file_name() { assert(has_source_information()); return m_src_file_name->bytes; } - /** Gets a method localed at method_idx in + /** + * Gets a method localed at method_idx in * the m_vtable_descriptors table. + * * @param method_idx - index of method in vtable descriptors table - * @return A method from the vtable descriptors table.*/ + * + * @return A method from the vtable descriptors table. + */ Method* get_method_from_vtable(unsigned method_idx) const { return m_vtable_descriptors[method_idx]; } - /** Gets the first subclass for Class Hierarchy Analysis. - * @return The first subclass.*/ + /** + * Gets the first subclass for Class Hierarchy Analysis. + * + * @return The first subclass. + */ Class* get_first_child() const { return m_cha_first_child; } - /** Return the next sibling for Class Hierarchy Analysis. - * @return The next sibling.*/ + /** + * Return the next sibling for Class Hierarchy Analysis. + * + * @return The next sibling. + */ Class* get_next_sibling() const { return m_cha_next_sibling; } - /** Gets offset of m_depth field in struct Class. + /** + * Gets offset of m_depth field in struct Class. + * * @param dummy - dummy variable used to calculate field offset - * @note Instanceof helpers use returned offset.*/ + * + * @note Instanceof helpers use returned offset. + */ static size_t get_offset_of_depth(Class* dummy) { return (size_t)((char*)(&dummy->m_depth) - (char*)dummy); } - /** Gets offset of m_is_suitable_for_fast_instanceof field in struct Class. + /** + * Gets offset of m_is_suitable_for_fast_instanceof field + * in struct Class. + * * @param dummy - dummy variable used to calculate field offset - * @note Instanceof helper uses returned offset.*/ + * + * @note Instanceof helper uses returned offset. + */ static size_t get_offset_of_fast_instanceof_flag(Class* dummy) { return (size_t)((char*)(&dummy->m_is_suitable_for_fast_instanceof) - (char*)dummy); } - /** Gets an offset of m_is_fast_allocation_possible in + /** + * Gets an offset of m_is_fast_allocation_possible in * the class. - * @note Allocation helpers use returned offset.*/ + * + * @note Allocation helpers use returned offset. + */ size_t get_offset_of_fast_allocation_flag() { // else one byte ld in helpers will fail assert(sizeof(m_is_fast_allocation_possible) == 1); return (size_t)((char*)(&m_is_fast_allocation_possible) - (char*)this); } - /** Gets an offset of m_allocation_handle in the class. - * @note Allocation helpers use returned offset.*/ + /** + * Gets an offset of m_allocation_handle in the class. + * + * @note Allocation helpers use returned offset. + */ size_t get_offset_of_allocation_handle() { assert(sizeof(m_allocation_handle) == sizeof(void*)); return (size_t)((char*)(&m_allocation_handle) - (char*)this); } - /** Gets an offset of m_instance_data_size in the class. - * @note Allocation helpers use returned offset.*/ + /** + * Gets an offset of m_instance_data_size in the class. + * + * @note Allocation helpers use returned offset. + */ size_t get_offset_of_instance_data_size() { assert(sizeof(m_instance_data_size) == 4); return (size_t)((char*)(&m_instance_data_size) - (char*)this); } - /** Gets an offset of m_num_class_init_checks in the class. + /** + * Gets an offset of m_num_class_init_checks in the class. + * * @param dummy - dummy variable used to calculate field offset - * @note Class initialization helper on IPF uses returned offset.*/ + * + * @note Class initialization helper on IPF uses returned offset. + */ static size_t get_offset_of_class_init_checks(Class* dummy) { return (size_t)((char*)(&dummy->m_num_class_init_checks) - (char*)dummy); } - /** Gets an offset of m_array_element_class in the class. + /** + * Gets an offset of m_array_element_class in the class. + * * @param dummy - dummy variable used to calculate field offset - * @note Class initialization helper on IPF uses returned offset.*/ + * + * @note Class initialization helper on IPF uses returned offset. + */ static size_t get_offset_of_array_element_class(Class* dummy) { assert(sizeof(dummy->m_array_element_class) == sizeof(void*)); return (size_t)((char*)(&dummy->m_array_element_class) - (char*)dummy); } - /** Gets the number of array dimensions. - * @return Number of dimentions in an array represented by this class.*/ + /** + * Gets the number of array dimensions. + * + * @return Number of dimentions in an array represented by this class. + */ unsigned char get_number_of_dimensions() const { assert(is_array()); return m_num_dimensions; } - /** Gets the class of the array element. + /** + * Gets the class of the array element. + * * @return Class describing the element of an array - * represented by this class.*/ + * represented by this class. + */ Class* get_array_element_class() const { assert(is_array()); return m_array_element_class; } - /** Gets the array-element type descriptor. + /** + * Gets the array-element type descriptor. + * * @return Type descriptor for the element of an array - * represented by this class.*/ + * represented by this class. + */ TypeDesc* get_array_element_type_desc() const { assert(is_array()); return m_array_element_type_desc; } - /** Gets the class state. - * @return The class state.*/ + /** + * Gets the class state. + * + * @return The class state. + */ Class_State get_state() const { return m_state; } - /** Gets a number of superinterfaces. - * @return A number of superinterfaces of the given class.*/ + /** + * Gets a number of superinterfaces. + * + * @return A number of superinterfaces of the given class. + */ uint16 get_number_of_superinterfaces() const { return m_num_superinterfaces; } - /** Gets a super-interface name from the array of super-interfaces that + /** + * Gets a super-interface name from the array of super-interfaces that * the given class implements. + * * @param[in] index - an index of super-interface to return the name for - * @return The requested super-interface name.*/ + * + * @return The requested super-interface name. + */ const String* get_superinterface_name(uint16 index) const { assert(index < m_num_superinterfaces); return m_superinterfaces[index].name; } - /** Gets a superinterface from the array of superinterfaces the given class + /** + * Gets a superinterface from the array of superinterfaces the given class * implements. + * * @param[in] index - an index of a superinterface to return - * @return A requested superinterface.*/ + * + * @return A requested superinterface. + */ Class* get_superinterface(uint16 index) const { assert(index < m_num_superinterfaces); return m_superinterfaces[index].clss; } - /** Gets a constant pool of the given class. - * @return A constant pool of the given class.*/ + /** + * Gets a constant pool of the given class. + * + * @return A constant pool of the given class. + */ ConstantPool& get_constant_pool() { return m_const_pool; } - /** Gets a number of fields in the given class. - * @return A number of fields in the given class.*/ + /** + * Gets a number of fields in the given class. + * + * @return A number of fields in the given class. + */ uint16 get_number_of_fields() const { return m_num_fields; } - /** Gets a number of static fields in the given class. - * @return A number of static fields in the given class.*/ + /** + * Gets a number of static fields in the given class. + * + * @return A number of static fields in the given class. + */ uint16 get_number_of_static_fields() const { return m_num_static_fields; } - /** Gets a field from the given class by its position in the class-fields + /** + * Gets a field from the given class by its position in the class-fields * array. + * * @param[in] index - an index in the class-fields array of a field to * retrieve - * @return The requested field.*/ + * + * @return The requested field. + */ Field* get_field(uint16 index) const; - /** Gets an address of the memory block containing static data of + /** + * Gets an address of the memory block containing static data of * the given class. - * @return An address of a static data block.*/ + * + * @return An address of a static data block. + */ void* get_static_data_address() const { return m_static_data_block; } - /** Gets a number of methods in the given class. - * @return A number of methods in the given class.*/ + /** + * Gets a number of methods in the given class. + * + * @return A number of methods in the given class. + */ uint16 get_number_of_methods() const { return m_num_methods; } - /** Gets a method from the given class by its position in the + /** + * Gets a method from the given class by its position in the * class-method array. + * * @param[in] index - an index in the class-method array of a * method to retrieve - * @return A requested method.*/ + * + * @return A requested method. + */ Method* get_method(uint16 index) const; - /** Gets a constant-pool index of the declaring class. + /** + * Gets a constant-pool index of the declaring class. + * * @return An index in the constant pool describing the requested - * declaring class.*/ + * declaring class. + */ uint16 get_declaring_class_index() const { return m_declaring_class_index; } - /** Gets a constant-pool index of the enclosing class. + /** + * Gets a constant-pool index of the enclosing class. + * * @return An index in the constant pool describing the requested - * enclosing class.*/ + * enclosing class. + */ uint16 get_enclosing_class_index() const { return m_enclosing_class_index; } - /** Gets a constant-pool index of the enclosing method. + /** + * Gets a constant-pool index of the enclosing method. + * * @return An index in the constant pool describing the requested enclosing - * method.*/ + * method. + */ uint16 get_enclosing_method_index() const { return m_enclosing_method_index; } - /** Gets a number of inner classes. - * @return A number of inner classes.*/ + /** + * Gets a number of inner classes. + * + * @return A number of inner classes. + */ uint16 get_number_of_inner_classes() const { return m_num_innerclasses; } - /** Gets an index in the constant pool of the given class, which + /** + * Gets an index in the constant pool of the given class, which * describes the inner class. + * * @param[in] index - an index of the inner class in the array of * inner classes in the given class * @return An index in the constant pool describing the requested inner - * class.*/ + * class. + */ uint16 get_inner_class_index(uint16 index) const { assert(index < m_num_innerclasses); return m_innerclasses[index].index; } - /** Gets access flags for the inner class. + /** + * Gets access flags for the inner class. + * * @param[in] index - an index of the inner class in the array of inner * classes in the given class - * @return Access flags of the requested inner class.*/ + * + * @return Access flags of the requested inner class. + */ uint16 get_inner_class_access_flags(uint16 index) const { assert(index < m_num_innerclasses); return m_innerclasses[index].access_flags; } - /** Gets a collection of annotations. - * @return A collection of annotations.*/ + /** + * Gets a collection of annotations. + * + * @return A collection of annotations. + */ AnnotationTable* get_annotations() const { return m_annotations; } - /** Gets a class instance size. - * @return A size of the allocated instance in bytes.*/ + /** + * Gets a class instance size. + * + * @return A size of the allocated instance in bytes. + */ unsigned int get_allocated_size() const { return m_allocated_size; } unsigned int get_instance_data_size() const { return m_instance_data_size & NEXT_TO_HIGH_BIT_CLEAR_MASK; } - /** Gets the array-alement size. + /** + * Gets the array-alement size. + * * @return A size of the array element. - * @note The given function assumes that the class is an array class.*/ + * + * @note The given function assumes that the class is an array class. + */ unsigned int get_array_element_size() const { assert(m_is_array == 1); return m_array_element_size; } - /** Gets the class ID.*/ + /** + * Gets the class ID. + */ unsigned get_id() const { return m_id; } - /** Gets major version of class file. - * @return Major version of class file.*/ + /** + * Gets major version of class file. + * + * @return Major version of class file. + */ uint16 get_version() const { return m_version; } - /** Gets access and properties flags of the given class. + /** + * Gets access and properties flags of the given class. + * * @return The 16-bit integer representing access and properties flags - * the given class.*/ + * the given class. + */ uint16 get_access_flags() const { return m_access_flags; } - /** Checks whether the given class represents the primitive type. - * @return true if the class is primitive; otherwise - * false.*/ + /** + * Checks whether the given class represents the primitive type. + * + * @return TRUE if the class is primitive; otherwise + * FALSE. + */ bool is_primitive() const { return m_is_primitive == 1; } - /** Checks whether the given class represents an array. - * @return true if the given class is an array, otherwise - * false.*/ + /** + * Checks whether the given class represents an array. + * + * @return TRUE if the given class is an array, otherwise + * FALSE. + */ bool is_array() const { return m_is_array == 1; } - /** Checks whether the base class of the given array is primitive. - * @return true if the base class is primitive, otherwise - * false.*/ + /** + * Checks whether the base class of the given array is primitive. + * + * @return TRUE if the base class is primitive, otherwise + * FALSE. + */ bool is_array_of_primitives() const { return m_is_array_of_primitives == 1; } - /** Checks whether the class has the ACC_PUBLIC flag set. - * @return true if the class has the ACC_PUBLIC - * access flag set.*/ + /** + * Checks whether the class has the ACC_PUBLIC flag set. + * + * @return TRUE if the class has the ACC_PUBLIC + * access flag set. + */ bool is_public() const { return (m_access_flags & ACC_PUBLIC) != 0; } - /** Checks whether the class has the ACC_PUBLIC flag set. - * @return true if the class has the ACC_PUBLIC - * access flag set.*/ + /** + * Checks whether the class has the ACC_PUBLIC flag set. + * + * @return TRUE if the class has the ACC_PUBLIC + * access flag set. + */ bool is_private() const { return (m_access_flags & ACC_PRIVATE) != 0; } - /** Checks whether the class has the ACC_PUBLIC flag set. - * @return true if the class has the ACC_PUBLIC - * access flag set.*/ + /** + * Checks whether the class has the ACC_PUBLIC flag set. + * + * @return TRUE if the class has the ACC_PUBLIC + * access flag set. + */ bool is_protected() const { return (m_access_flags & ACC_PROTECTED) != 0; } - /** Checks whether the class has the ACC_FINAL flag set. - * @return true if the class has the ACC_FINAL - * access flag set.*/ + /** + * Checks whether the class has the ACC_FINAL flag set. + * + * @return TRUE if the class has the ACC_FINAL + * access flag set. + */ bool is_final() const { return (m_access_flags & ACC_FINAL) != 0; } - /** Checks whether the class has the ACC_SUPER flag set. - * @return true if the class has the ACC_SUPER - * access flag set.*/ + /** + * Checks whether the class has the ACC_SUPER flag set. + * + * @return TRUE if the class has the ACC_SUPER + * access flag set. + */ bool is_super() const { return (m_access_flags & ACC_SUPER) != 0; } - /** Checks whether the class has the ACC_INTERFACE flag set. - * @return true if the class has the ACC_INTERFACE - * access flag set.*/ + /** + * Checks whether the class has the ACC_INTERFACE flag set. + * + * @return TRUE if the class has the ACC_INTERFACE + * access flag set. + */ bool is_interface() const { return (m_access_flags & ACC_INTERFACE) != 0; } - /** Checks whether the class has the ACC_ABSTRACT flag set. - * @return true if the class has the ACC_ABSTRACT - * access flag set.*/ + /** + * Checks whether the class has the ACC_ABSTRACT flag set. + * + * @return TRUE if the class has the ACC_ABSTRACT + * access flag set. + */ bool is_abstract() const { return (m_access_flags & ACC_ABSTRACT) != 0; } - /** Checks whether the class is enum, that is the ACC_ENUM + /** + * Checks whether the class is enum, that is the ACC_ENUM * flag is set. - * @return true if the class is enum.*/ + * + * @return TRUE if the class is enum. + */ bool is_enum() const { return (m_access_flags & ACC_ENUM) != 0; } - /** Checks whether the class has the ACC_SYNTHETIC flag set. - * @return true if the class has the ACC_SYNTHETIC - * access flag set.*/ + /** + * Checks whether the class has the ACC_SYNTHETIC flag set. + * + * @return TRUE if the class has the ACC_SYNTHETIC + * access flag set. + */ bool is_synthetic() const { return (m_access_flags & ACC_SYNTHETIC) != 0; } - /** Checks whether the class is an annotation. - * @return true if the class is an annotation.*/ + /** + * Checks whether the class is an annotation. + * + * @return TRUE if the class is an annotation. + */ bool is_annotation() const { return (m_access_flags & ACC_ANNOTATION) != 0; } - /** Checks whether the given class has a finalizer. - * @return true if the given class (or its super class) has - * a finalize method; otherwise false.*/ + /** + * Checks whether the given class has a finalizer. + * + * @return TRUE if the given class (or its super class) has + * a finalize method; otherwise FALSE. + */ bool has_finalizer() const { return m_has_finalizer == 1; } - /** Checks whether the given class is an inner class of some other class. - * @return true if the given class is an inner class of some - * other class, otherwise false.*/ + /** + * Checks whether the given class is an inner class of some other class. + * + * @return TRUE if the given class is an inner class of some + * other class, otherwise FALSE. + */ bool is_inner_class() const { return m_declaring_class_index != 0; } - /** Checks whether the given class can access inner_class. + /** + * Checks whether the given class can access inner_class. + * * @param[in] env - VM environment * @param[in] inner_class - an inner class to check access to - * @return true if the given class has access to the inner - * class; otherwise false.*/ + * + * @return TRUE if the given class has access to the inner + * class; otherwise FALSE. + */ bool can_access_inner_class(Global_Env* env, Class* inner_class); - /** Checks whether the given class can access a member class. + /** + * Checks whether the given class can access a member class. + * * @param[in] member - a class member to check access to - * @return true if the given class can access a member class; - * otherwise false.*/ + * + * @return TRUE if the given class can access a member class; + * otherwise FALSE. + */ bool can_access_member(Class_Member* member); - /** Checks whether the given class has a source-file name available. - * @return true if source file name is available for the given class; - * otherwise false.*/ + /** + * Checks whether the given class has a source-file name available. + * + * @return TRUE if source file name is available for the given class; + * otherwise FALSE. + */ bool has_source_information() const { return m_src_file_name != NULL; } - /** Checks whether the given class is in the process of initialization. - * @return true if the class initialization method is executed; - * otherwise false.*/ + /** + * Checks whether the given class is in the process of initialization. + * + * @return TRUE if the class initialization method is executed; + * otherwise FALSE. + */ bool is_initializing() const { return m_state == ST_Initializing; } - /** Checks whether the class is initialized. - * @return true if the class is initialized; - * otherwise false.*/ + /** + * Checks whether the class is initialized. + * + * @return TRUE if the class is initialized; + * otherwise FALSE. + */ bool is_initialized() const { return m_state == ST_Initialized; } - /** Checks whether the class is in the error state. - * @return true if the class is in the error state; - * otherwise false.*/ + /** + * Checks whether the class is in the error state. + * + * @return TRUE if the class is in the error state; + * otherwise FALSE. + */ bool in_error() const { return m_state == ST_Error; } - /** Checks whether the given class has a passed preparation stage. - * @return true if the class has a passed preparation stage; - * otherwise false.*/ + /** + * Checks whether the given class has a passed preparation stage. + * + * @return TRUE if the class has a passed preparation stage; + * otherwise FALSE. + */ bool is_at_least_prepared() const { return m_state == ST_Prepared || m_state == ST_ConstraintsVerified @@ -1487,63 +2025,94 @@ || m_state == ST_Initialized; } - /** Checks whether the given class represents a class that is a subtype of + /** + * Checks whether the given class represents a class that is a subtype of * clss, according to the Java instance of rules. + * * @param[in] clss - a class to check for being super relative - * @return true if the given class represents a class that is - * a subtype of clss, otherwise false.*/ + * + * @return TRUE if the given class represents a class that is + * a subtype of clss, otherwise FALSE. + */ bool is_instanceof(Class* clss); - /** FIXME: all setter functions must be rethought to become private + /** + * FIXME: all setter functions must be rethought to become private * or to be removed altogether, if possible. * Sets the name of a file from which the given class has been loaded. - * @param[in] cf_name - a class-file name*/ + * + * @param[in] cf_name - a class-file name + */ void set_class_file_name(const String* cf_name) { assert(cf_name); m_class_file_name = cf_name; } - /** Sets instance data size constraint bit to let the allocation know + /** + * Sets instance data size constraint bit to let the allocation know * there are constraints on the way instance should be allocated. + * * @note Constaints are recorded in the class_properties - * field of the class VTable.*/ + * field of the class VTable. + */ void set_instance_data_size_constraint_bit() { m_instance_data_size |= NEXT_TO_HIGH_BIT_SET_MASK; } - /** Sets a class handle of java.lang.Class for the given class. - * @param[in] oh - a class handle of java.lang.Class*/ + /** + * Sets a class handle of java.lang.Class for the given class. + * + * @param[in] oh - a class handle of java.lang.Class + */ void set_class_handle(ManagedObject** oh) { m_class_handle = oh; } - /** Constructs internal representation of a class from the byte array + /** + * Constructs internal representation of a class from the byte array * (defines class). + * * @param[in] env - VM environment - * @param[in] cfs - a class-file stream; byte array contaning class data*/ + * @param[in] cfs - a class-file stream; byte array contaning class data + */ bool parse(Global_Env* env, ByteReader& cfs); - /** Loads a super class and super interfaces of the given class. + /** + * Loads a super class and super interfaces of the given class. * The given class's class loader is used for it. - * @param[in] env - VM environment*/ + * + * @param[in] env - VM environment + */ bool load_ancestors(Global_Env* env); - /** Verifies bytecodes of the class. + /** + * Verifies bytecodes of the class. + * * @param[in] env - VM environment - * @return true if bytecodes of a class were successfully verified; - * otherwise false.*/ + * + * @return TRUE if bytecodes of a class were successfully verified; + * otherwise false. + */ bool verify(const Global_Env* env); - /** Verifies constraints for the given class collected during the bytecodes + /** + * Verifies constraints for the given class collected during the bytecodes * verification. + * * @param[in] env - VM environment - * @return true if constraints successfully pass verification; - * otherwise false.*/ + * + * @return TRUE if constraints successfully pass verification; + * otherwise false. + */ bool verify_constraints(const Global_Env* env); - /** Setups the given class as representing a primitive type. + /** + * Setups the given class as representing a primitive type. + * * @param[in] cl - a class loader the given class belongs to + * * @note FIXME: cl is always a bootstrap class loader * for primitive types. Retrieve the bootstrap class loader - * from VM environment here, not one level up the calling stack.*/ + * from VM environment here, not one level up the calling stack. + */ void setup_as_primitive(ClassLoader* cl) { m_is_primitive = 1; m_class_loader = cl; @@ -1551,7 +2120,9 @@ m_state = ST_Initialized; } - /** Sets up the given class as representing an array. + /** + * Sets up the given class as representing an array. + * * @param[in] env - VM environment * @param[in] num_dimentions - a number of dimentions this array has * @param[in] isArrayOfPrimitives - does this array is an array of primitives @@ -1561,12 +2132,15 @@ * @param[in] elementClass - class representing element of this array; * for example, for [[I, element * the class is [I + * * @note For single-dimentional arrays baseClass and - * elementClass are the same.*/ + * elementClass are the same. + */ void setup_as_array(Global_Env* env, unsigned char num_dimensions, bool isArrayOfPrimitives, Class* baseClass, Class* elementClass); - /** Prepares a class:
    + /** + * Prepares a class:
      *
    1. assigns offsets: * - the offset of instance data fields * - virtual methods in a vtable @@ -1574,87 +2148,132 @@ *
    2. creates a class vtable
    3. *
    4. creates a static field block
    5. *
    6. creates a static method block
    + * * @param[in] env - vm environment - * @return true if the class was successfully prepared; - * otherwise false.*/ + * + * @return TRUE if the class was successfully prepared; + * otherwise false. + */ bool prepare(Global_Env* env); - /** Resolves a constant-pool entry to a class. Loads a class if neccessary. + /** + * Resolves a constant-pool entry to a class. Loads a class if neccessary. + * * @param[in] env - VM environment * @param[in] cp_index - a constant-pool index of CONSTANT_Class * to resolve + * * @return A resolved class, if a resolution attempt succeeds; * otherwise NULL. + * * @note Should become private as soon as wrappers become members of the - * struct #Class.*/ + * struct #Class. + */ Class* _resolve_class(Global_Env* env, unsigned cp_index); - /** Resolves a declaring class. + /** + * Resolves a declaring class. + * * @return A declaring class, if the given class is inner class of some * other class and if the resolution was successful; - * otherwise NULL.*/ + * otherwise NULL. + */ Class* resolve_declaring_class(Global_Env* env); - /** Resolves a field in the constant pool of the given class. + /** + * Resolves a field in the constant pool of the given class. + * * @param[in] env - VM environment * @param[in] cp_index - an index of an entry in the constant pool, * which describes field to be resolved + * * @return A resolved field, if a resolution attempt succeeds; * otherwise NULL. + * * @note Should become private as soon as wrappers - * become members of the struct #Class.*/ + * become members of the struct #Class. + */ Field* _resolve_field(Global_Env* env, unsigned cp_index); - /** Resolves a method in the constant pool of the given class. + /** + * Resolves a method in the constant pool of the given class. + * * @param[in] env - VM environment * @param[in] cp_index - an index of an entry in the constant pool, * which describes method to be resolved + * * @return A resolved method, if a resolution attempt succeeds; * otherwise NULL. + * * @note Should become private as soon as wrappers become members of - * the struct #Class.*/ + * the struct #Class. + */ Method* _resolve_method(Global_Env* env, unsigned cp_index); - /** Initializes the class. + /** + * Initializes the class. + * * @param[in] throw_exception - defines whether the exception should * be thrown or raised + * * @note The given method may raise exception, if an error occurs during - * the initialization of the class.*/ + * the initialization of the class. + */ void initialize(); - /** Looks up the field with specified name and descriptor in the given class only. + /** + * Looks up the field with specified name and descriptor in the given + * class only. + * * @param[in] name - the field name to look up for * @param[in] desc - the field descriptor to look up for + * * @return The looked up field if found in the given class, - * otherwise NULL.*/ + * otherwise NULL. + */ Field* lookup_field(const String* name, const String* descriptor); - /** Looks up the field with specified name and descriptor in the given class - * and also in the super class and super-interfaces recursively. + /** + * Looks up the field with specified name and descriptor in the given class + * and also in the super class and super-interfaces recursively. + * * @param[in] name - field name to look up for * @param[in] desc - field descriptor to look up for - * @return The looked up field if found, NULL otherwise*/ + * + * @return The looked up field if found, NULL otherwise. + */ Field* lookup_field_recursive(const String* name, const String* descriptor); - /** Looks up a method with a specified name and descriptor in the given + /** + * Looks up a method with a specified name and descriptor in the given * class only. + * * @param[in] name - a method name to look up for * @param[in] desc - a method descriptor to look up for + * * @return The looked-up method, if found in the given class; - * otherwise NULL.*/ + * otherwise NULL. + */ Method* lookup_method(const String* name, const String* desc); - /** Allocates an instance of the given class and returns a pointer to it. + /** + * Allocates an instance of the given class and returns a pointer to it. + * * @return A managed pointer to the allocated class instance; * NULL, if no memory is available and * OutOfMemoryError exception is raised on a - * caller thread.*/ + * caller thread. + */ ManagedObject* allocate_instance(); - /** Calculates a size of the block allocated for the array, which is represented by + /** + * Calculates a size of the block allocated for the array, which is represented by * the given class. + * * @param[in] length - the length of the array - * @return The size of the array of specified length in bytes.*/ + * + * @return The size of the array of specified length in bytes. + */ unsigned calculate_array_size(int length) const { assert(length >= 0); assert(is_array()); @@ -1671,340 +2290,535 @@ return size; } - /** Estimates the amount of memory allocated for C++ part of the given class. - * @return The size of memory allocated for the given class.*/ + /** + * Estimates the amount of memory allocated for C++ part of the given class. + * + * @return The size of memory allocated for the given class. + */ unsigned calculate_size(); - /** Gets the interface vtable for interface iid within + /** + * Gets the interface vtable for interface iid within * object obj. + * * @param[in] obj - an object to retrieve an interface table entry from * @param[in] iid - an interface class to retrieve vtable for + * * @return An interface vtable from object; NULL, if no - * such interface exists for the object.*/ + * such interface exists for the object. + */ void* helper_get_interface_vtable(ManagedObject* obj, Class* iid); - /** Registers a callback that is called to notify the given JIT + /** + * Registers a callback that is called to notify the given JIT * whenever the given class is extended. The callback_data * pointer will be passed back to the JIT during the callback. The JIT's callback * function is JIT_extended_class_callback. + * * @param[in] jit_to_be_notified - JIT to notify on extending the class * @param[in] callback_data - data to be passed back to JIT, when the callback - * is called*/ + * is called + */ void register_jit_extended_class_callback(JIT* jit_to_be_notified, void* callback_data); - /** Calls registered JITs callbacks to notify that the given class was + /** + * Calls registered JITs callbacks to notify that the given class was * extended by new_class. - * @param[in] new_subclass - a subclass extending the given class*/ + * + * @param[in] new_subclass - a subclass extending the given class + */ void do_jit_extended_class_callbacks(Class* new_subclass); // SourceDebugExtension class attribute support - /** Checks whether the given class has the + /** + * Checks whether the given class has the * SourceDebugExtension attribute. - * @return true if the SourceDebugExtension + * + * @return TRUE if the SourceDebugExtension * attribute is available for the given class; - * otherwise false.*/ + * otherwise false. + */ bool has_source_debug_extension() const { return m_sourceDebugExtension != NULL; } - /** Gets length of the SourceDebugExtension attribute. - * @return The SourceDebugExtension attribute length.*/ + /** + * Gets length of the SourceDebugExtension attribute. + * + * @return The SourceDebugExtension attribute length. + */ unsigned get_source_debug_extension_length() const { return m_sourceDebugExtension->len; } - /** Gets data from the SourceDebugExtension attribute. - * @return SourceDebugExtension attribute bytes.*/ + /** + * Gets data from the SourceDebugExtension attribute. + * + * @return SourceDebugExtension attribute bytes. + */ const char* get_source_debug_extension() const { return m_sourceDebugExtension->bytes; } // Class unloading support - /** Checks whether the given class is reachable through its loader + /** + * Checks whether the given class is reachable through its loader * or any live object. - * @return true if the given class is reachable, - * otherwise false.*/ + * + * @return TRUE if the given class is reachable, + * otherwise false. + */ bool is_reachable() { return m_markBit == 1; } - /** Clears a reachability mark.*/ + /** + * Clears a reachability mark. + */ void reset_reachable() { m_markBit = 0; } - /** Marks the given class as reachable.*/ + /** + * Marks the given class as reachable. + */ void mark_reachable() { m_markBit = 1; } - /** Stores a verifier specific pointer into the given class. - * @param[in] data - a verifier specific data pointer*/ + /** + * Stores a verifier specific pointer into the given class. + * + * @param[in] data - a verifier specific data pointer + */ void set_verification_data(void* data) { assert(m_verify_data == NULL); m_verify_data = data; } - /** Gets a pointer to verifier specific data, previously stored with + /** + * Gets a pointer to verifier specific data, previously stored with * the call to set_verification_data. + * * @return A pointer to verifier specific data or NULL, if - * none was set.*/ + * none was set. + */ void* get_verification_data() { return m_verify_data; } - /** Locks access to the given class.*/ + /** + * Locks access to the given class. + */ void lock(); - /** Unlocks access to the given class.*/ + /** + * Unlocks access to the given class. + */ void unlock(); // Statistics update - /** Updates allocation statistics. - * @param[in] size - a size of an allocated instance*/ + /** + * Updates allocation statistics. + * + * @param[in] size - a size of an allocated instance + */ void instance_allocated(unsigned size) { m_num_allocations++; m_num_bytes_allocated += size; } - /** Updates an instance of slow path statistics.*/ + /** + * Updates an instance of slow path statistics. + */ void instanceof_slow_path_taken() { m_num_instanceof_slow++; } - /** Updates throwing statistics for java/lang/Throwable decendants.*/ + /** + * Updates throwing statistics for java/lang/Throwable decendants. + */ void class_thrown() { m_num_throws++; } - /** Allocates memory for code from pool of defining classloader for the class.*/ + /** + * Allocates memory for code from pool of defining classloader for the class. + */ void* code_alloc(size_t size, size_t alignment, Code_Allocation_Action action); - /** Updates initialization check statistics.*/ + /** + * Updates initialization check statistics. + */ void initialization_checked() { m_num_class_init_checks++; } - /** Gets the number of times instance of the given class was allocated. - * @return The number of allocations of the given class.*/ + /** + * Gets the number of times instance of the given class was allocated. + * + * @return The number of allocations of the given class. + */ uint64 get_times_allocated() const { return m_num_allocations; } - /** Gets the total number of bytes allocated for instances of the given class. - * @return The number of bytes allocated for all instances of the given class.*/ + /** + * Gets the total number of bytes allocated for instances of the given class. + * + * @return The number of bytes allocated for all instances of the given class. + */ uint64 get_total_bytes_allocated() const { return m_num_bytes_allocated; } - /** Gets the number of times the slow path of the check instance was taken. - * @return The number of times the slow path was taken.*/ + /** + * Gets the number of times the slow path of the check instance was taken. + * + * @return The number of times the slow path was taken. + */ uint64 get_times_instanceof_slow_path_taken() const { return m_num_instanceof_slow; } - /** Gets the number of times the given class was thrown. - * @return The number of times the given class was thrown.*/ + /** + * Gets the number of times the given class was thrown. + * + * @return The number of times the given class was thrown. + */ uint64 get_times_thrown() const { return m_num_throws; } - /** Gets the number of times the initialization of the given class + /** + * Gets the number of times the initialization of the given class * was checked by run-time helpers. - * @return The number of times initialization of the given class was checked.*/ + * + * @return The number of times initialization of the given class was checked. + */ uint64 get_times_init_checked() const { return m_num_class_init_checks; } - /** Gets the number of excessive bytes used for aligning class fields. - * @return A number of excessive bytes used for aligning class fields.*/ + /** + * Gets the number of excessive bytes used for aligning class fields. + * + * @return A number of excessive bytes used for aligning class fields. + */ uint64 get_total_padding_bytes() const { return m_num_field_padding_bytes; } private: - /** Parses super-interfaces information from a class-file stream. + /** + * Parses super-interfaces information from a class-file stream. + * * @param[in] cfs - a class-file stream to parse superinterfaces information from - * @return true if information was succesfully parsed; - * otherwise false.*/ + * + * @return TRUE if information was succesfully parsed; + * otherwise false. + */ bool parse_interfaces(ByteReader &cfs); - /** Parses class fields from a class-file stream. + /** + * Parses class fields from a class-file stream. + * * @param[in] env - VM enviroment * @param[in] cfs - a class-file stream - * @return true if successfully parses fields; false - * if any parse error occurs.*/ + * + * @return TRUE if successfully parses fields; FALSE + * if any parse error occurs. + */ bool parse_fields(Global_Env* env, ByteReader &cfs); - /** Parses class methods from a class-file stream. + /** + * Parses class methods from a class-file stream. + * * @param[in] env - VM enviroment * @param[in] cfs - a class file stream - * @return true if successfully parses methods; false - * if any parse error occurs.*/ + * + * @return TRUE if successfully parses methods; FALSE + * if any parse error occurs. + */ bool parse_methods(Global_Env* env, ByteReader &cfs); - /** Calculates and assigns offsets to class fields during preparation.*/ + /** + * Calculates and assigns offsets to class fields during preparation. + */ void assign_offsets_to_fields(); - /** Assign offsets to class-instance fields. + /** + * Assign offsets to class-instance fields. + * * @param[in] field_ptrs - an array of class fields to assign * offsets to * @param[in] do_field_compaction - defines whether the class fields should - * be compacted*/ + * be compacted + */ void assign_offsets_to_instance_fields(Field** field_ptrs, bool do_field_compaction); - /** Assigns an offset to an instance field. + /** + * Assigns an offset to an instance field. + * * @param[in] field - a field to calculate offset for * @param[in] do_field_compaction - defines whether the class fields should - * be compacted*/ + * be compacted + */ void assign_offset_to_instance_field(Field* field, bool do_field_compaction); - /** Assigns offsets to static fields of a class. + /** + * Assigns offsets to static fields of a class. + * * @param[in] field_ptrs - an array of fields * @param[in] do_field_compaction - defines whether the class fields should - * be compacted*/ + * be compacted + */ void assign_offsets_to_static_fields(Field** field_ptrs, bool do_field_compaction); - /** Initializes an interface class. - * @return true if the interface was successfully initialized; - * otherwise false.*/ + /** + * Initializes an interface class. + * + * @return TRUE if the interface was successfully initialized; + * otherwise FALSE. + */ bool initialize_static_fields_for_interface(); - /** Assigns offsets (from the base of the vtable) and the VTable index to - * class methods. - * @param[in] env - VM environment*/ + /** + * Assigns offsets (from the base of the vtable) and the VTable + * index to class methods. + * + * @param[in] env - VM environment + */ void assign_offsets_to_methods(Global_Env* env); - /** Creates the vtable for the given class. - * @param[in] n_vtable_entries - a number of entries for the vtable*/ + /** + * Creates the vtable for the given class. + * + * @param[in] n_vtable_entries - a number of entries for the vtable + */ void create_vtable(unsigned n_vtable_entries); - /** Populates the vtable descriptors table with methods overriding as neccessary.*/ + /** + * Populates the vtable descriptors table with methods overriding as neccessary. + */ void populate_vtable_descriptors_table_and_override_methods(); - /** Creates and populates an interface table for a class. - * @return The created interface table.*/ + /** + * Creates and populates an interface table for a class. + * + * @return The created interface table. + */ Intfc_Table* create_and_populate_interface_table(); - /** Constructs an interface table descriptors table.*/ + /** + * Constructs an interface table descriptors table. + */ void build_interface_table_descriptors(); - /** Sets vtable entries to methods addresses.*/ + /** + * Sets vtable entries to methods addresses. + */ void point_vtable_entries_to_stubs(); - /** Adds any required "fake" methods to a class. These are interface methods + /** + * Adds any required "fake" methods to a class. These are interface methods * inherited by an abstract class that are not implemented by that class * or any superclass. Such methods will never be called, but they are added * so they have the correct offset in the virtual method part of the vtable - * (that is the offset of the "real" method in the vtable for a concrete class).*/ + * (that is the offset of the "real" method in the vtable for a concrete class). + */ void add_any_fake_methods(); }; // struct Class } // extern "C" -/** Gets instance of java/lang/Class associated with this class. - * @param[in] clss - class to retrieve java/lang/Class instance for. - * @return Instance of java/lang/Class associated with class.*/ +/** + * Gets instance of java/lang/Class associated with this class. + * + * @param[in] clss - class to retrieve java/lang/Class instance for. + * + * @return Instance of java/lang/Class associated with class. + */ ManagedObject* struct_Class_to_java_lang_Class(Class* clss); -/** Gets handle of java/lang/Class instance associated with this class. - * @param[in] clss - class to retrieve handle with java/lang/Class instance for. - * @return Handle with instance of java/lang/Class associated with class. +/** + * Gets handle of java/lang/Class instance associated with this class. + * + * @param[in] clss - class to retrieve handle with java/lang/Class + * instance for + * + * @return Handle with instance of java/lang/Class associated with + * class. + * * @note This function allocates local handle and stores reference to - * java/lang/Class into it.*/ + * java/lang/Class into it. + */ jclass struct_Class_to_jclass(Class* clss); -/** Gets native class from the java/lang/Class handle. - * @param[in] jc - handle to retrieve struct Class from. - * @return Class for the given handle.*/ +/** + * Gets native class from the java/lang/Class handle. + * + * @param[in] jc - handle to retrieve struct Class from + * + * @return Class for the given handle. + */ Class* jclass_to_struct_Class(jclass jc); -/** Gets native class for any given object handle. - * @param[in] jobj - object to retrieve class for. - * @return Class for the given object handle.*/ +/** + * Gets native class for any given object handle. + * + * @param[in] jobj - object to retrieve class for + * + * @return Class for the given object handle. + */ Class* jobject_to_struct_Class(jobject jobj); -/** Gets pointer to instance of java/lang/Class associated with the class. - * @param[in] clss - class to retrieve pointer to instance of java/lang/Class for. - * @return Pointer to instance of java/lang/Class associated with the class. +/** + * Gets pointer to instance of java/lang/Class associated with the + * class. + * + * @param[in] clss - class to retrieve pointer to instance of + * java/lang/Class for + * + * @return Pointer to instance of java/lang/Class associated with + * the class. + * * @note This is NOT real handle, so, when using this function, make sure the - * returned value will never be passed to ANY user code including JVMTI - * agent callbacks.*/ + * returned value will never be passed to ANY user code including JVMTI + * agent callbacks. + */ jobject struct_Class_to_java_lang_Class_Handle(Class* clss); -/** Gets native class from instance of java/lang/Class. - * @param[in] jlc - instance of java/lang/Class to retrieve class from. - * @return Native class from instance of java/lang/Class.*/ +/** + * Gets native class from instance of java/lang/Class. + * + * @param[in] jlc - instance of java/lang/Class to retrieve + * class from + * + * @return Native class from instance of java/lang/Class. + */ Class* java_lang_Class_to_struct_Class(ManagedObject* jlc); -/** Looks up field in class and its superclasses. - * @param[in] clss - class to lookup field in. - * @param[in] name - name of the field. - * @param[in] desc - descriptor of the field. - * @return Requested field, if the field exists, NULL otherwise.*/ +/** + * Looks up field in class and its superclasses. + * + * @param[in] clss - class to lookup field in + * @param[in] name - name of the field + * @param[in] desc - descriptor of the field + * + * @return Requested field, if the field exists, NULL otherwise. + */ Field* class_lookup_field_recursive(Class* clss, const char* name, const char* desc); -/** Looks up method in class and its superclasses. - * @param[in] clss - class to lookup method in. - * @param[in] name - name of the method as VM String. - * @param[in] desc - descriptor of the method as VM String. +/** + * Looks up method in class and its superclasses. + * + * @param[in] clss - class to lookup method in + * @param[in] name - name of the method as VM String + * @param[in] desc - descriptor of the method as VM String + * * @return Requested method, if the method exists, * NULL otherwise. - * @note VMEXPORT specifier is solely for interpreter.*/ + * + * @note VMEXPORT specifier is solely for interpreter. + */ VMEXPORT Method* class_lookup_method_recursive(Class* clss, const String* name, const String* desc); -/** Looks up method in class and its superclasses. - * @param[in] clss - class to lookup method in. - * @param[in] name - name of the method. - * @param[in] desc - descriptor of the method. +/** + * Looks up method in class and its superclasses. + * + * @param[in] clss - class to lookup method in + * @param[in] name - name of the method + * @param[in] desc - descriptor of the method + * * @return Requested method, if the method exists, - * NULL otherwise.*/ + * NULL otherwise. + */ Method* class_lookup_method_recursive(Class* clss, const char* name, const char* desc); -/** Looks up method in the given class only. - * @param[in] clss - class to lookup method in. - * @param[in] name - name of the method. - * @param[in] desc - descriptor of the method. +/** + * Looks up method in the given class only. + * + * @param[in] clss - class to lookup method in + * @param[in] name - name of the method + * @param[in] desc - descriptor of the method + * * @return Requested method, if the method exists, - * NULL otherwise.*/ + * NULL otherwise. + */ Method* class_lookup_method(Class* clss, const char* name, const char* desc); -/** Gets method given its offset in the vtable. - * @param[in] vt - vtable containing method. - * @param[in] offset - offset of the method in the vtable. - * @return Method at the specified offset.*/ +/** + * Gets method given its offset in the vtable. + * + * @param[in] vt - vtable containing method + * @param[in] offset - offset of the method in the vtable + * + * @return Method at the specified offset. + */ Method* class_get_method_from_vt_offset(VTable* vt, unsigned offset); -/** Resolves non-static field at the specified index in +/** + * Resolves non-static field at the specified index in * the constant pool of the class. - * @param[in] clss - class to resolve field in. - * @param[in] cp_index - index in the constant pool of the class. + * + * @param[in] clss - class to resolve field in + * @param[in] cp_index - index in the constant pool of the class + * * @return Resolved field, if resolution succeeded, - * NULL otherwise.*/ + * NULL otherwise. + */ Field* class_resolve_nonstatic_field(Class* clss, unsigned cp_index); - -/** Loads a class and performs the first two parts of the link process: +/** + * Loads a class and performs the first two parts of the link process: * verify and prepare. - * @param[in] env - VM environment. - * @param[in] classname - name of a class to load. - * @param[in] cl - class loader to load class with. + * + * @param[in] env - VM environment + * @param[in] classname - name of a class to load + * @param[in] cl - class loader to load class with + * * @return Loaded class, if loading and linking succeeded, - * NULL otherwise.*/ + * NULL otherwise. + */ Class* class_load_verify_prepare_by_loader_jni(Global_Env* env, const String* classname, ClassLoader* cl); -/** Loads a class with bootstrap class loader and performs the first two parts +/** + * Loads a class with bootstrap class loader and performs the first two parts * of the link process: verify and prepare. - * @param[in] env - VM environment. - * @param[in] classname - name of a class to load. - * @param[in] cl - class loader to load class with. + * + * @param[in] env - VM environment + * @param[in] classname - name of a class to load + * @param[in] cl - class loader to load class with + * * @return Loaded class, if loading and linking succeeded, * NULL otherwise. - * @note The class is loaded .*/ + * + * @note The class is loaded. + */ Class* class_load_verify_prepare_from_jni(Global_Env* env, const String* classname); -/** Executes static initializer of class. - * @param[in] clss - class to initialize.*/ +/** + * Executes static initializer of class. + * + * @param[in] clss - class to initialize + */ void class_initialize_from_jni(Class *clss); -/** Executes static initializer of class. - * @param[in] clss - class to initialize.*/ +/** + * Executes static initializer of class. + * + * @param[in] clss - class to initialize + */ void class_initialize_ex(Class *clss); -/** Executes static initializer of class. - * @param[in] clss - class to initialize. - * @note VMEXPORT specifier is solely for interpreter.*/ +/** + * Executes static initializer of class. + * + * @param[in] clss - class to initialize + * + * @note VMEXPORT specifier is solely for interpreter. + */ VMEXPORT void class_initialize(Class *clss); -/** Registers a number of native methods to a given class. +/** + * Registers a number of native methods to a given class. + * * @param[in] klass - a specified class * @param[in] methods - an array of methods * @param[in] num_methods - a number of methods - * @return false, if methods resistration is successful; - * otherwise true. + * + * @return FALSE, if methods resistration is successful; + * otherwise TRUE. + * * @note Function raises NoSuchMethodError with the method name in * exception message, if one of the methods in the JNINativeMethod* - * array is not present in a specified class.*/ + * array is not present in a specified class. + */ bool class_register_methods(Class_Handle klass, const JNINativeMethod* methods, int num_methods); -/** Unregisters a native methods off a given class. +/** + * Unregisters a native methods off a given class. + * * @param[in] klass - specified class - * @return false, if methods unresistration is successful; - * otherwise true.*/ + * + * @return FALSE, if methods unresistration is successful; + * otherwise TRUE. + */ bool class_unregister_methods(Class_Handle klass);