From 0bf6d2aa52ab0006d44844c2baa77f4bca0e82b1 Mon Sep 17 00:00:00 2001 From: Igor Rudenko Date: Sun, 22 Sep 2024 00:24:45 +0300 Subject: [PATCH] jdescription test fix --- jdescriptor/src/lib.rs | 4 ++-- vm/src/class_loader.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/jdescriptor/src/lib.rs b/jdescriptor/src/lib.rs index 470bfca4..ea2052d3 100644 --- a/jdescriptor/src/lib.rs +++ b/jdescriptor/src/lib.rs @@ -322,8 +322,8 @@ mod tests { #[test] fn should_return_error_for_object_without_closing_symbol() { assert_eq!( - str::parse::("["), - Err("Unexpected end of input".to_string()) + str::parse::("Ljava/lang/String"), + Err("Missing ';' in class name descriptor".to_string()) ); } #[test] diff --git a/vm/src/class_loader.rs b/vm/src/class_loader.rs index 6886c08d..a22e83a6 100644 --- a/vm/src/class_loader.rs +++ b/vm/src/class_loader.rs @@ -90,9 +90,12 @@ impl ClassLoader { get_cpool_string(class_file, method.descriptor_index() as usize).ok_or( Error::new_constant_pool("Error getting method method_signature"), )?; - let (max_stack, max_locals, code) = - Self::get_cpool_code_attribute(method.attributes()) - .ok_or(Error::new_constant_pool(format!("Error getting method code: {class_name}.{method_name}(...)").as_str()))?; + let (max_stack, max_locals, code) = Self::get_cpool_code_attribute( + method.attributes(), + ) + .ok_or(Error::new_constant_pool( + format!("Error getting method code: {class_name}.{method_name}(...)").as_str(), + ))?; let key_signature = method_name + ":" + method_signature.as_str(); method_by_signature.insert(