RFR: 8350880: (zipfs) Add support for read-only zip file systems [v12]

Alan Bateman alanb at openjdk.org
Sat May 24 06:31:55 UTC 2025


On Fri, 23 May 2025 23:25:59 GMT, Xueming Shen <sherman at openjdk.org> wrote:

> Looks like I'm late to the party :-) My apologies if this has already been discussed a long time ago. My question is whether it's really necessary to restrict the 'read-only' flag to existing ZIP files only. I don't see any issue with allowing the creation of a new, empty ZIP file and marking it as read-only. Sure, it might be useless since it's just an empty zip file system, but that's up to the user. Not a very strong opinion though.

In the file system API, the "CREATE" option is specified to be ignored when opening a file for only reading. This means an I/O exception if the file doesn't exist. This was a pragmatic choice at the time that requires the full table of combinations and their outcome to see.

For zipfs, the doing the same, or rejecting having the env contain both create=true and accessMode=readOnly, is okay. We chatted with David about this recently and agreed that rejecting this combination makes the most sense. It means someone has opt'ed it for both options, which is different to the file system API where it defaults to "READ" if none of the read/write/append options are provided.

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

PR Comment: https://git.openjdk.org/jdk/pull/25178#issuecomment-2906503159


More information about the core-libs-dev mailing list