@@ -42,6 +42,7 @@ impl String {
4242 JavaMethodProto :: new( "toString" , "()Ljava/lang/String;" , Self :: to_string, Default :: default ( ) ) ,
4343 JavaMethodProto :: new( "charAt" , "(I)C" , Self :: char_at, Default :: default ( ) ) ,
4444 JavaMethodProto :: new( "getBytes" , "()[B" , Self :: get_bytes, Default :: default ( ) ) ,
45+ JavaMethodProto :: new( "getChars" , "(II[CI)V" , Self :: get_chars, Default :: default ( ) ) ,
4546 JavaMethodProto :: new( "toCharArray" , "()[C" , Self :: to_char_array, Default :: default ( ) ) ,
4647 JavaMethodProto :: new( "toUpperCase" , "()Ljava/lang/String;" , Self :: to_upper_case, Default :: default ( ) ) ,
4748 JavaMethodProto :: new( "length" , "()I" , Self :: length, Default :: default ( ) ) ,
@@ -254,6 +255,33 @@ impl String {
254255 Ok ( byte_array. into ( ) )
255256 }
256257
258+ async fn get_chars (
259+ jvm : & Jvm ,
260+ _: & mut RuntimeContext ,
261+ this : ClassInstanceRef < Self > ,
262+ src_begin : i32 ,
263+ src_end : i32 ,
264+ mut dst : ClassInstanceRef < Array < JavaChar > > ,
265+ dst_begin : i32 ,
266+ ) -> Result < ( ) > {
267+ tracing:: debug!(
268+ "java.lang.String::getChars({:?}, {}, {}, {:?}, {})" ,
269+ & this,
270+ src_begin,
271+ src_end,
272+ & dst,
273+ dst_begin
274+ ) ;
275+
276+ let value = jvm. get_field ( & this, "value" , "[C" ) . await ?;
277+
278+ let count = src_end - src_begin;
279+ let chars: Vec < JavaChar > = jvm. load_array ( & value, src_begin as _ , count as _ ) . await ?;
280+ jvm. store_array ( & mut dst, dst_begin as _ , chars) . await ?;
281+
282+ Ok ( ( ) )
283+ }
284+
257285 async fn to_char_array ( jvm : & Jvm , _: & mut RuntimeContext , this : ClassInstanceRef < Self > ) -> Result < ClassInstanceRef < Array < JavaChar > > > {
258286 tracing:: debug!( "java.lang.String::toCharArray({:?})" , & this) ;
259287
0 commit comments