Implements the native method 'readBytes'.
183 {
184#if FIRST_PASS
185 throw new NotImplementedException();
186#else
187 var fd = FileInputStreamAccessor.GetFd(self);
188 if (fd == null)
189 throw new global::java.io.IOException("The handle is invalid.");
190
191 if (FileDescriptorAccessor.GetStream(fd) is Stream stream)
192 {
193 if (len == 0)
194 return 0;
195
196 if ((off < 0) || (off > bytes.Length) || (len < 0) || (len > (bytes.Length - off)))
197 throw new global::java.lang.IndexOutOfBoundsException();
198
199 if (stream.CanRead == false)
200 throw new global::java.io.IOException("Read failed.");
201
202 try
203 {
204 var n = stream.Read(bytes, off, len);
205 return n == 0 ? -1 : n;
206 }
207 catch (ObjectDisposedException e)
208 {
209 throw new global::java.io.IOException(e.Message);
210 }
211 catch (NotSupportedException e)
212 {
213 throw new global::java.io.IOException(e.Message);
214 }
215 catch (IOException e)
216 {
217 throw new global::java.io.IOException(e.Message);
218 }
219 }
220 else
221 {
222 __callerID ??= global::ikvm.@internal.CallerID.create(typeof(global::java.io.FileInputStream).TypeHandle);
223 __jniPtr__readBytes ??= Marshal.GetDelegateForFunctionPointer<__jniDelegate__readBytes>(
JNIFrame.
GetFuncPtr(__callerID,
"java/io/FileInputStream", nameof(
readBytes),
"([BII)I"));
225 var jniEnv = jniFrm.Enter(__callerID);
226 try
227 {
228 return __jniPtr__readBytes(jniEnv, jniFrm.MakeLocalRef(self), jniFrm.MakeLocalRef(bytes), off, len);
229 }
230 catch (Exception ex)
231 {
232 System.Console.WriteLine(
"*** exception in native code ***");
233 System.Console.WriteLine(ex);
234 throw;
235 }
236 finally
237 {
238 jniFrm.Leave();
239 }
240 }
241#endif
242 }