@@ -114,7 +114,9 @@ impl RandomAccessFile {
114114 let mut rust_file = FileDescriptor :: file ( jvm, context, fd) . await ?;
115115
116116 let mut rust_buf = vec ! [ 0 ; length as usize ] ;
117- let read = super :: checked ( jvm, rust_file. read ( & mut rust_buf) . await ) . await ?;
117+ let Ok ( read) = rust_file. read ( & mut rust_buf) . await else {
118+ return Err ( jvm. exception ( "java/io/IOException" , "I/O error" ) . await ) ;
119+ } ;
118120
119121 jvm. array_raw_buffer_mut ( & mut buf) . await ?. write ( offset as _ , & rust_buf) ?;
120122
@@ -145,7 +147,9 @@ impl RandomAccessFile {
145147
146148 let mut rust_buf = vec ! [ 0 ; length as usize ] ;
147149 jvm. array_raw_buffer ( & buf) . await ?. read ( offset as _ , & mut rust_buf) ?;
148- super :: checked ( jvm, rust_file. write ( & cast_vec ( rust_buf) ) . await ) . await ?;
150+ if rust_file. write ( & cast_vec ( rust_buf) ) . await . is_err ( ) {
151+ return Err ( jvm. exception ( "java/io/IOException" , "I/O error" ) . await ) ;
152+ }
149153
150154 Ok ( ( ) )
151155 }
@@ -156,7 +160,9 @@ impl RandomAccessFile {
156160 let fd = jvm. get_field ( & this, "fd" , "Ljava/io/FileDescriptor;" ) . await ?;
157161 let mut rust_file = FileDescriptor :: file ( jvm, context, fd) . await ?;
158162
159- super :: checked ( jvm, rust_file. seek ( pos as _ ) . await ) . await ?;
163+ if rust_file. seek ( pos as _ ) . await . is_err ( ) {
164+ return Err ( jvm. exception ( "java/io/IOException" , "I/O error" ) . await ) ;
165+ }
160166
161167 Ok ( ( ) )
162168 }
@@ -167,7 +173,9 @@ impl RandomAccessFile {
167173 let fd = jvm. get_field ( & this, "fd" , "Ljava/io/FileDescriptor;" ) . await ?;
168174 let mut rust_file = FileDescriptor :: file ( jvm, context, fd) . await ?;
169175
170- super :: checked ( jvm, rust_file. set_len ( new_length as _ ) . await ) . await ?;
176+ if rust_file. set_len ( new_length as _ ) . await . is_err ( ) {
177+ return Err ( jvm. exception ( "java/io/IOException" , "I/O error" ) . await ) ;
178+ }
171179
172180 Ok ( ( ) )
173181 }
@@ -178,7 +186,10 @@ impl RandomAccessFile {
178186 let fd = jvm. get_field ( & this, "fd" , "Ljava/io/FileDescriptor;" ) . await ?;
179187 let rust_file = FileDescriptor :: file ( jvm, context, fd) . await ?;
180188
181- let len = super :: checked ( jvm, rust_file. metadata ( ) . await ) . await ?. size ;
189+ let Ok ( metadata) = rust_file. metadata ( ) . await else {
190+ return Err ( jvm. exception ( "java/io/IOException" , "I/O error" ) . await ) ;
191+ } ;
192+ let len = metadata. size ;
182193
183194 Ok ( len as i64 )
184195 }
@@ -189,7 +200,9 @@ impl RandomAccessFile {
189200 let fd = jvm. get_field ( & this, "fd" , "Ljava/io/FileDescriptor;" ) . await ?;
190201 let rust_file = FileDescriptor :: file ( jvm, context, fd) . await ?;
191202
192- let pos = super :: checked ( jvm, rust_file. tell ( ) . await ) . await ?;
203+ let Ok ( pos) = rust_file. tell ( ) . await else {
204+ return Err ( jvm. exception ( "java/io/IOException" , "I/O error" ) . await ) ;
205+ } ;
193206
194207 Ok ( pos as i64 )
195208 }
0 commit comments