RFO: open RandomAccessFile with FILE_SHARE_DELETE on Windows

Maxim Kartashev maxim.kartashev at jetbrains.com
Thu Dec 25 07:04:31 UTC 2025


Hi All,

Currently, the following snippet will not succeed on Windows
try (RandomAccessFile ignored = new RandomAccessFile(f, "r")) {
    f.delete();
}
because RandomAccessFile is opened without the FILE_SHARE_DELETE option for
the CreateFileW() call.
I wonder if this is intentional and what, if anything, would break if this
decision is reversed and FILE_SHARE_DELETE is supplied? I suspect
applications rely on the existing semantics but can't give concrete
examples myself.

Appreciate your input.

Maxim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nio-dev/attachments/20251225/3e203a9e/attachment.htm>


More information about the nio-dev mailing list