RFR: 8356645: Javac should utilize new ZIP file system read-only access mode

David Beaumont duke at openjdk.org
Tue Jun 10 13:32:34 UTC 2025


On Fri, 6 Jun 2025 23:03:31 GMT, ExE Boss <duke at openjdk.org> wrote:

>> This PR seeks to integrate the new ZipFileSystem "accessMode" parameter to open internal ZIP/JAR files as read only, to act as defense in-depth against accidental modification.
>> 
>> Note that this currently also propagates the (currently undocumented) "zipinfo-time" parameter to several other places where ZIP/JAR files are opened, which is likely to improve performance. This was discussed and is expected to be safe (but it's something to be careful about).
>> This will, of course, be thoroughly tested before integration.
>> 
>> It also unifies several places to use a common helper method to obtain the environment map, adds more comments, and changes a small number of affected tests.
>> 
>> I'm also happy to update the original bug description to include the timestamp related changes as necessary.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java line 565:
> 
>> 563:             this.archivePath = archivePath;
>> 564:             // Common parameters for opening ZIP/JAR file systems in Javac.
>> 565:             Map<String, ?> env = FSInfo.readOnlyJarFSEnv(multiReleaseValue);
> 
> Note that this will now cause `.zip` files to be treated the same as `.jar` files when `multiReleaseValue ≠ null` (previously, this was ignored for `.zip` files)

That's an excellent point. I will be sure to ask people if that looks acceptable and revert to the original behaviour otherwise. Thank you for spotting it and saying something.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25639#discussion_r2137914138


More information about the compiler-dev mailing list