@@ -5,11 +5,9 @@ use core::{
55 fmt:: Debug ,
66 hash:: BuildHasher ,
77 iter,
8- mem:: { forget, size_of_val} ,
98 sync:: atomic:: { AtomicBool , Ordering } ,
109} ;
1110
12- use bytemuck:: cast_slice;
1311use dyn_clone:: clone_box;
1412use event_listener:: { Event , EventListener } ;
1513use hashbrown:: { DefaultHashBuilder , HashSet } ;
@@ -659,37 +657,6 @@ impl Jvm {
659657 Ok ( ( ) )
660658 }
661659
662- pub async fn get_rust_object_field < T > ( & self , instance : & Box < dyn ClassInstance > , name : & str ) -> Result < T >
663- where
664- T : Clone ,
665- {
666- let raw_storage = self . get_field ( instance, name, "[B" ) . await ?;
667- let length = self . array_length ( & raw_storage) . await ?;
668- let buf: Vec < i8 > = self . load_array ( & raw_storage, 0 , length) . await ?;
669-
670- let rust_raw = usize:: from_le_bytes ( cast_slice ( & buf) . try_into ( ) . unwrap ( ) ) ;
671-
672- let rust = unsafe { Box :: from_raw ( rust_raw as * mut T ) } ;
673- let result = ( * rust) . clone ( ) ;
674-
675- forget ( rust) ; // do not drop box as we still have it in java memory
676-
677- Ok ( result)
678- }
679-
680- pub async fn put_rust_object_field < T > ( & self , instance : & mut Box < dyn ClassInstance > , name : & str , value : T ) -> Result < ( ) > {
681- let rust_raw = Box :: into_raw ( Box :: new ( value) ) as * const u8 as usize ;
682-
683- let length = size_of_val ( & rust_raw) ;
684- let mut raw_storage = self . instantiate_array ( "B" , length) . await ?;
685- self . store_array ( & mut raw_storage, 0 , cast_slice :: < u8 , i8 > ( & rust_raw. to_le_bytes ( ) ) . to_vec ( ) )
686- . await ?;
687-
688- self . put_field ( instance, name, "[B" , raw_storage) . await ?;
689-
690- Ok ( ( ) )
691- }
692-
693660 pub fn attach_thread ( & self ) -> Result < ( ) > {
694661 let thread_id = ( self . inner . get_current_thread_id ) ( ) ;
695662 self . inner . threads . write ( ) . insert ( thread_id, JvmThread :: new ( ) ) ;
0 commit comments