@@ -21,6 +21,12 @@ impl FileInputStream {
2121 interfaces : vec ! [ ] ,
2222 methods : vec ! [
2323 JavaMethodProto :: new( "<init>" , "(Ljava/io/File;)V" , Self :: init, Default :: default ( ) ) ,
24+ JavaMethodProto :: new(
25+ "<init>" ,
26+ "(Ljava/io/FileDescriptor;)V" ,
27+ Self :: init_with_file_descriptor,
28+ Default :: default ( ) ,
29+ ) ,
2430 JavaMethodProto :: new( "read" , "()I" , Self :: read_byte, Default :: default ( ) ) ,
2531 JavaMethodProto :: new( "read" , "([BII)I" , Self :: read_array, Default :: default ( ) ) ,
2632 JavaMethodProto :: new( "available" , "()I" , Self :: available, Default :: default ( ) ) ,
@@ -30,11 +36,9 @@ impl FileInputStream {
3036 }
3137 }
3238
33- async fn init ( jvm : & Jvm , context : & mut RuntimeContext , mut this : ClassInstanceRef < Self > , file : ClassInstanceRef < File > ) -> Result < ( ) > {
39+ async fn init ( jvm : & Jvm , context : & mut RuntimeContext , this : ClassInstanceRef < Self > , file : ClassInstanceRef < File > ) -> Result < ( ) > {
3440 tracing:: debug!( "java.io.FileInputStream::<init>({:?}, {:?})" , & this, & file) ;
3541
36- let _: ( ) = jvm. invoke_special ( & this, "java/io/InputStream" , "<init>" , "()V" , ( ) ) . await ?;
37-
3842 let path = jvm. invoke_virtual ( & file, "getPath" , "()Ljava/lang/String;" , ( ) ) . await ?;
3943 let path = JavaLangString :: to_rust_string ( jvm, & path) . await ?;
4044
@@ -46,6 +50,23 @@ impl FileInputStream {
4650
4751 let fd = FileDescriptor :: from_file ( jvm, rust_file. unwrap ( ) ) . await ?;
4852
53+ let _: ( ) = jvm
54+ . invoke_special ( & this, "java/io/FileInputStream" , "<init>" , "(Ljava/io/FileDescriptor;)V" , ( fd, ) )
55+ . await ?;
56+
57+ Ok ( ( ) )
58+ }
59+
60+ async fn init_with_file_descriptor (
61+ jvm : & Jvm ,
62+ _: & mut RuntimeContext ,
63+ mut this : ClassInstanceRef < Self > ,
64+ fd : ClassInstanceRef < FileDescriptor > ,
65+ ) -> Result < ( ) > {
66+ tracing:: debug!( "java.io.FileInputStream::<init>({:?}, {:?})" , & this, & fd) ;
67+
68+ let _: ( ) = jvm. invoke_special ( & this, "java/io/InputStream" , "<init>" , "()V" , ( ) ) . await ?;
69+
4970 jvm. put_field ( & mut this, "fd" , "Ljava/io/FileDescriptor;" , fd) . await ?;
5071
5172 Ok ( ( ) )
0 commit comments