On Wed, 23 Oct 2024 22:52:52 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

> Modify `FileInputStream` (FIS) to fall back to the superclass implementations 
> of `readAllBytes()`, `readNBytes(int)`, `skip()`, and `transferTo` when the 
> input source would otherwise fail with "Illegal Seek" in the FIS 
> implementation, such as for the standard input or a named pipe.

src/java.base/share/classes/java/io/FileInputStream.java line 334:

> 332:     @Override
> 333:     public byte[] readAllBytes() throws IOException {
> 334:         if (!canSeek())

Since `canSeek()` is implemented as a native call whose result depends on the 
file descriptor of this `FileInputStream`, do you think we should reduce these 
native calls in this change and call `canSeek()` just once (and store that 
state) in the constructors of this class?
If we do that, we might have to consider whether the 
`FileInputStream(FileDescriptor fdObj)` will end up throwing an exception (from 
the native canSeek() implementation) if the `FileDescriptor` passed to the 
constructor is not `valid()` 
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/io/FileDescriptor.html#valid()

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21673#discussion_r1814797437

Reply via email to