-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Read only ZIP file system. #24506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Read only ZIP file system. #24506
Conversation
👋 Welcome back david-beaumont! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@david-beaumont The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-loading to give context for some of the changes.
@@ -180,7 +251,26 @@ class ZipFileSystem extends FileSystem { | |||
this.provider = provider; | |||
this.zfpath = zfpath; | |||
|
|||
initializeReleaseVersion(env); | |||
// Determining a release version uses 'this' instance to read paths etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving all the mutable instance state to the end of the constructor, so we can more easily reason about what state its in when the entry lookup remapping is built.
} | ||
createVersionedLinks(version < 0 ? 0 : version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now done in the caller (constructor) because it was a hidden side-effecting method.
@@ -1435,11 +1531,11 @@ private boolean isMultiReleaseJar() throws IOException { | |||
* Then wrap the map in a function that getEntry can use to override root | |||
* entry lookup for entries that have corresponding versioned entries. | |||
*/ | |||
private void createVersionedLinks(int version) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to return the map to the constructor. This could also be made to return Optional<...>
to maybe simplify caller.
@@ -163,4 +161,36 @@ public synchronized FileSystemProvider getJarFSProvider() { | |||
return null; | |||
} | |||
|
|||
// Should match the properties/values in ZipFileSystem.java. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a helper here (it seemed like the right place). Happy to move or inline stuff.
} catch (ZipException ze) { | ||
throw new IOException("ZipException opening \"" + archivePath.getFileName() + "\": " + ze.getMessage(), ze); | ||
} | ||
} else { | ||
this.fileSystem = FileSystems.newFileSystem(archivePath, (ClassLoader)null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing code is passing null, but that constructor path is identical to the ones not passing a classloader at all.
I'm not sure if the old code was calling the version for additional clarity-of-intent, but the new code has the same effect wrt class loaders.
| UncheckedIOException | ||
| FileSystemNotFoundException | ||
| InvalidPathException | ||
| ReadOnlyFileSystemException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is just about adding slightly more useful information to the (common) case when no exception message exists. It helped me when debugging.
private final Set<PosixFilePermission> defaultPermissions; | ||
|
||
private final Set<String> supportedFileAttributeViews; | ||
|
||
// If it's decided to try and make access mode common to other file systems, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to think it might be possible to make a common access mode for any file system, but it's probably a long way off. Right now I'm reticent to make this enum public (because if it were a common property later we'd need to move the type or support both). Happy to rethink depending on what others think though.
static AccessMode from(Object value) { | ||
switch (value) { | ||
case null -> { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using null rather than a "default" instance it's more in tune with what we'd expose in terms of a user facing enum, and I wanted to just align what's here with that (even if we aren't doing it yet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dave,
Thank you for taking on this enhancement to zipfs.
It would be best to:
- Have separate PRs for the javac and zipfs changes
- Keep the zipfs changes to what is required to support "read-only" file systems
-- Additional cleanup can be done under a separate PR in order to keep the changes more narrowly focused - As part of this change, there should be additional test(s) added to the zipfs area which test the proposed behavior as well as what happens when conflicting values are provided
This a draft review not intended to be reviewed yet. I'm just having the discussion around the changes privately for now. Please don't bother looking at it until it's out of draft status. I do hope you weren't assigned as a reviewer automatically on a draft PR ?! |
3e44b27
to
0935cb8
Compare
* Reverting and simplifying some things after discussion. * Fix bad test. * Repatching javac changes. * Minor fix for env. * Making Javac only ever create read-only ZIP/JAR filesystems.
* Rewording module info.
…tually exclusive.
0935cb8
to
e8aff8f
Compare
Draft for pre-review comments.
This is NOT intended to be a single PR that's submitted (I'm including at least 2 things together here so things like internal helper function API changes can be seen in context).
Please do not review this unless you've reached out to me first for proper context.
Progress
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24506/head:pull/24506
$ git checkout pull/24506
Update a local copy of the PR:
$ git checkout pull/24506
$ git pull https://git.openjdk.org/jdk.git pull/24506/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24506
View PR using the GUI difftool:
$ git pr show -t 24506
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24506.diff