Struct rust_jvm::vm::class::Class
[−]
[src]
pub struct Class { pub symref: Class, pub access_flags: u16, pub superclass: Option<Rc<Class>>, constant_pool: RuntimeConstantPool, fields: HashMap<Field, u16>, field_constants: HashMap<Field, constant_pool_index>, methods: HashMap<Method, Method>, field_values: RefCell<Option<HashMap<Field, Value>>>, }
A JVM representation of a class that has been loaded.
Fields
symref | A symbolic reference to the class, comprised of its name (if a scalar type) or element type (if an array class). |
access_flags | The access flags for the class. |
superclass | The superclass extended by the class. If the class is |
constant_pool | The runtime constant pool of the current class, created from the constant pool defined in
the |
fields | The fields of this class mapped to their access flags. This map includes both |
field_constants | The constants which populate the |
methods | The methods of the class, mapped to their method structures. |
field_values | The values of the static fields of this class. These are only set at class initialization.
§5.5 of the JVM spec requires that initialization occur only at certain specific points,
in particular:
* When an instance of the class is created with the |
Methods
impl Class
fn new(symref: Class, superclass: Option<Rc<Class>>, constant_pool: RuntimeConstantPool, class_file: ClassFile) -> Self
fn new_array(object_class: Rc<Class>, component_access_flags: u16, component_type: Type) -> Self
Create a new array class for a given element type.
fn get_symref(&self) -> Class
fn get_access_flags(&self) -> u16
fn get_constant_pool(&self) -> &RuntimeConstantPool
fn resolve_method(&self, method_symref: &Method) -> &Method
Find the method in the current class referred to by a given symbolic reference. If the
method is not found, panics with a NoSuchMethodError
.
fn find_method(&self, method_sig: &Method) -> Option<&Method>
Implements dynamic lookup of a method's signature in the current class. If no method with the given signature is found, then recursively searches the current class's superclasses.
fn dispatch_method(&self, resolved_method: &Method) -> Option<(&Class, &Method)>
Implements dynamic dispatch of a resolved method according to the lookup procedure
specified for the invokevirtual
instruction. Method resolution depends on whether the
method in question overrides a superclass method. (See spec for more information.)
fn is_descendant(&self, other: &Class) -> bool
Returns true if this class is a descendant (direct or indirect subclass) of another class.
fn initialize(&self, class_loader: &mut ClassLoader)
Initialize the class by executing its class or interface initialization method. Prior to initialization, a class or interface must be linked, that is, verified, prepared, and optionally resolved.
fn resolve_and_get_field(&self, symref: &Field, class_loader: &mut ClassLoader) -> Value
Resolves a symbolic reference to a field and reads a value from that field.
fn resolve_and_put_field(&self, symref: &Field, new_value: Value, class_loader: &mut ClassLoader)
Resolves a symbolic reference to a field and writes a new value to that field.
fn collect_instance_fields(&self) -> HashSet<Field>
Returns a set of the signatures of the fields of an instance of this class.