Preload java/lang/ref/Reference

This commit is contained in:
vegowotenks 2024-11-15 11:14:35 +01:00
parent 5cf17d5ca3
commit c4da80f23c
4 changed files with 173 additions and 9 deletions

View file

@ -211,7 +211,8 @@ impl JVM {
attributes: Box::new([]),
};
self.class_store.add_class(array_class_file, true).unwrap();
let class_index = self.class_store.add_class(array_class_file, true).unwrap();
self.class_store.set_class_objectref_by_index(class_index, array_class_object);
self.class_store.put_array_class_ref(
array_type_description,
@ -509,6 +510,7 @@ impl JVM {
JVMCallbackOperation::ThrowException(exception) => {
let mut is_handler_found = false;
let exception_type_index = self.heap_area.object_area.get_object_class_index(exception);
while ! is_handler_found {
is_handler_found = {
let frame = {
@ -520,7 +522,6 @@ impl JVM {
if method.is_native() {
false
} else {
let exception_type_index = self.heap_area.object_area.get_object_class_index(exception);
class.is_method_bytecode_protected(method, frame.instruction_pointer as u16, exception_type_index, &self.class_store)?
}
};
@ -2279,6 +2280,17 @@ impl JVM {
return Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Double(double)));
}
Instruction::ReturnFloat() => {
match (method.descriptor.return_type.array_level, &method.descriptor.return_type.kind) {
(0, AbstractTypeKind::Float()) => (),
_ => return Err(Error::OpcodeError(format!("Found opcode '{:?}' on method returning '{:?}'", instruction, method.descriptor.return_type)))
}
let float = wrap_stackframe_error(class, method, frame.operand_stack.pop_float(0))?;
return Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Float(float)));
}
Instruction::ReturnInt() => {
match (method.descriptor.return_type.array_level, &method.descriptor.return_type.kind) {
(_, AbstractTypeKind::Byte() | AbstractTypeKind::Boolean()| AbstractTypeKind::Int() | AbstractTypeKind::Char() | AbstractTypeKind::Short()) => (),