On Mon, 30 Nov 2026 20:27:12 GMT, Sean Coffey <[email protected]> wrote:

> This patch overrides toString() in FileInputStream, FileOutputStream, and 
> RandomAccessFile to return the file's base name followed by its identity 
> hash. It follows similar changes made a few years ago for ZipFile 
> (JDK-8319626). 
> 
> Filename retrieval shares the existing File.getName() logic, while streams 
> constructed from a file descriptor retain their previous behaviour.
> 
> ---------
> - [X] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

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

> 1: /*

Copyright year needs a bump.

src/java.base/share/classes/java/io/FileOutputStream.java line 1:

> 1: /*

Copyright year needs a bump.

test/jdk/java/io/FileInputStream/ToString.java line 45:

> 43:     private static void check(Object object) {
> 44:         String expected = FILE.getFileName()
> 45:                 + "@" + 
> Integer.toHexString(System.identityHashCode(object));

Shall we also test `FOS`/`FIS`/`RAF` subclasses with custom `hashCode()` 
implementations?

test/jdk/java/io/FileInputStream/ToString.java line 60:

> 58:         try (FileOutputStream stream = new 
> FileOutputStream(FILE.toFile())) {
> 59:             check(stream);
> 60:         }

`FIS` and `FOS` are only exercised with a path. Could you also test file 
descriptor cases (i.e., `{FIS,FOS}#new(FileDescriptor)`) too, please?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/34137#discussion_r4752197016
PR Review Comment: https://git.openjdk.org/jdk/pull/34137#discussion_r4752200690
PR Review Comment: https://git.openjdk.org/jdk/pull/34137#discussion_r4753386151
PR Review Comment: https://git.openjdk.org/jdk/pull/34137#discussion_r4753374767

Reply via email to