@@ -154,7 +154,7 @@ use crate::JavaError::BootstrapMethodError;
154154use crate :: frame:: { ExecutionResult , Frame } ;
155155use crate :: operand_stack:: OperandStack ;
156156use crate :: thread:: Thread ;
157- use crate :: { JavaObject , Result , VM } ;
157+ use crate :: { JavaObject , Result } ;
158158use ristretto_classfile:: attributes:: { Attribute , BootstrapMethod } ;
159159use ristretto_classfile:: { Constant , ConstantPool , FieldType , MethodAccessFlags , ReferenceKind } ;
160160use ristretto_classloader:: { Class , ConcurrentVec , Method , ObjectArray , Reference , Value } ;
@@ -291,18 +291,14 @@ async fn resolve_method_handles_lookup(thread: &Thread) -> Result<Value> {
291291/// that represents that type in the JVM. For primitive types and arrays, this returns the
292292/// corresponding class objects (like `java.lang.Integer.TYPE` for `int`). For reference types, it
293293/// loads the class for the specified type.
294- async fn get_field_type_class (
295- vm : & VM ,
296- thread : & Thread ,
297- field_type : Option < FieldType > ,
298- ) -> Result < Value > {
294+ async fn get_field_type_class ( thread : & Thread , field_type : Option < FieldType > ) -> Result < Value > {
299295 let class_name = if let Some ( field_type) = field_type {
300296 field_type. class_name ( )
301297 } else {
302298 "void" . to_string ( )
303299 } ;
304300 let class = thread. class ( class_name) . await ?;
305- class. to_object ( vm ) . await
301+ class. to_object ( thread ) . await
306302}
307303
308304/// **Step 3.2** Create MethodType from method descriptor:
@@ -315,9 +311,9 @@ async fn get_field_type_class(
315311/// This function parses the provided method descriptor into its constituent parts (argument types
316312/// and return type), creates `Class` objects for each type, and then invokes the appropriate
317313/// `MethodType.methodType()` factory method to create a `MethodType` instance.
318- async fn get_method_type ( vm : & VM , thread : & Thread , method_descriptor : & str ) -> Result < Value > {
314+ async fn get_method_type ( thread : & Thread , method_descriptor : & str ) -> Result < Value > {
319315 let ( argument_types, return_type) = FieldType :: parse_method_descriptor ( method_descriptor) ?;
320- let return_class = get_field_type_class ( vm , thread, return_type) . await ?;
316+ let return_class = get_field_type_class ( thread, return_type) . await ?;
321317
322318 let method_type_class = thread. class ( "java.lang.invoke.MethodType" ) . await ?;
323319 if argument_types. is_empty ( ) {
@@ -330,10 +326,10 @@ async fn get_method_type(vm: &VM, thread: &Thread, method_descriptor: &str) -> R
330326 . await ;
331327 }
332328
333- let first_argument = get_field_type_class ( vm , thread, argument_types. first ( ) . cloned ( ) ) . await ?;
329+ let first_argument = get_field_type_class ( thread, argument_types. first ( ) . cloned ( ) ) . await ?;
334330 let argument_classes = ConcurrentVec :: from ( Vec :: with_capacity ( argument_types. len ( ) - 1 ) ) ;
335331 for argument_type in argument_types. iter ( ) . skip ( 1 ) {
336- let argument_class = get_field_type_class ( vm , thread, Some ( argument_type. clone ( ) ) ) . await ?;
332+ let argument_class = get_field_type_class ( thread, Some ( argument_type. clone ( ) ) ) . await ?;
337333 let argument_reference: Reference = argument_class. try_into ( ) ?;
338334 argument_classes. push ( Some ( argument_reference) ) ?;
339335 }
@@ -360,17 +356,17 @@ async fn get_method_type(vm: &VM, thread: &Thread, method_descriptor: &str) -> R
360356///
361357/// This function obtains a lookup object that has the access privileges of the caller's class. The
362358/// lookup object is used for finding and binding methods during dynamic method invocation.
363- async fn resolve_method_handle ( vm : & VM , thread : & Thread , frame : & Frame ) -> Result < Value > {
359+ async fn resolve_method_handle ( thread : & Thread , frame : & Frame ) -> Result < Value > {
364360 let lookup = resolve_method_handles_lookup ( thread) . await ?;
365361
366362 // Get the caller MethodHandle
367363 let class = frame. class ( ) ;
368- let class_object = class. to_object ( vm ) . await ?;
364+ let class_object = class. to_object ( thread ) . await ?;
369365 let method = frame. method ( ) ;
370366 let method_name = method. name ( ) ;
371- let method_name_object = method_name. to_object ( vm ) . await ?;
367+ let method_name_object = method_name. to_object ( thread ) . await ?;
372368 let method_descriptor = method. descriptor ( ) ;
373- let method_type = get_method_type ( vm , thread, method_descriptor) . await ?;
369+ let method_type = get_method_type ( thread, method_descriptor) . await ?;
374370 let mut arguments = vec ! [ method_name_object, method_type] ;
375371
376372 let lookup_class = thread
@@ -421,7 +417,7 @@ async fn resolve_method_handle(vm: &VM, thread: &Thread, frame: &Frame) -> Resul
421417/// in the constant pool. This function resolves those arguments from the constant pool and creates
422418/// arguments vector.
423419async fn resolve_static_bootstrap_arguments (
424- vm : & Arc < VM > ,
420+ thread : & Arc < Thread > ,
425421 constant_pool : & ConstantPool ,
426422 bootstrap_method : & BootstrapMethod ,
427423) -> Result < Vec < Value > > {
@@ -443,7 +439,7 @@ async fn resolve_static_bootstrap_arguments(
443439 }
444440 Constant :: String ( value) => {
445441 let string = constant_pool. try_get_utf8 ( * value) ?;
446- let value = string. to_object ( vm ) . await ?;
442+ let value = string. to_object ( thread ) . await ?;
447443 arguments. push ( value) ;
448444 }
449445 _ => {
@@ -511,12 +507,12 @@ pub async fn resolve_call_site(frame: &Frame, method_index: u16) -> Result<Value
511507 ) ;
512508
513509 // Invoke the bootstrap method
514- let vm = thread. vm ( ) ?;
515- let method_handle = resolve_method_handle ( & vm, & thread, frame) . await ?;
510+ let method_handle = resolve_method_handle ( & thread, frame) . await ?;
516511 let static_arguments =
517- resolve_static_bootstrap_arguments ( & vm, constant_pool, & bootstrap_method_attribute) . await ?;
518- let method_name = bootstrap_method_attr_name. to_object ( & vm) . await ?;
519- let method_type = get_method_type ( & vm, & thread, bootstrap_method_descriptor) . await ?;
512+ resolve_static_bootstrap_arguments ( & thread, constant_pool, & bootstrap_method_attribute)
513+ . await ?;
514+ let method_name = bootstrap_method_attr_name. to_object ( & thread) . await ?;
515+ let method_type = get_method_type ( & thread, bootstrap_method_descriptor) . await ?;
520516
521517 // 4.1 Construct argument array for bootstrap method:
522518 let mut arguments = vec ! [ method_handle, method_name, method_type] ;
0 commit comments