diff --git a/src/class.rs b/src/class.rs index e350ace..cf9a58a 100644 --- a/src/class.rs +++ b/src/class.rs @@ -365,7 +365,7 @@ pub struct BytecodeClass { pub instance_fields: Vec, // TODO flags pub class_identifier: ClassIdentifier, - pub super_class: Option>, + pub super_class: Rc, // TODO how are interfaces represented? pub interfaces: Vec>, // TODO attributes diff --git a/src/class/bytecode_classes.rs b/src/class/bytecode_classes.rs index 2ef88db..9a499f7 100644 --- a/src/class/bytecode_classes.rs +++ b/src/class/bytecode_classes.rs @@ -23,7 +23,7 @@ impl Class for BytecodeClass { } fn super_class(&self) -> Option> { - self.super_class.clone() + Some(self.super_class.clone()) } fn interfaces(&self) -> &[Rc] { diff --git a/src/classloader/class_creator.rs b/src/classloader/class_creator.rs index 0483a8d..389f6a4 100644 --- a/src/classloader/class_creator.rs +++ b/src/classloader/class_creator.rs @@ -209,14 +209,19 @@ pub fn create_bytecode_class( &runtime_cp[remove_cp_offset(class_file.this_class as usize)]; let class_identifier = parse_class_identifier(class.as_class().unwrap()); - let super_class = None; + let super_class_name: &RuntimeCPEntry = + &runtime_cp[remove_cp_offset(class_file.super_class as usize)]; + let super_class_identifier = + parse_class_identifier(super_class_name.as_class().unwrap()); + let super_class = heap.find_class(&super_class_identifier).unwrap(); + // let super_class = None; let interfaces = Vec::new(); BytecodeClass { methods, static_fields, instance_fields, class_identifier, - super_class, + super_class: super_class.clone(), interfaces, } }