[jdk11u-dev] RFR: 8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path
Amos Shi
ashi at openjdk.org
Mon Apr 22 18:55:30 UTC 2024
On Thu, 11 Apr 2024 06:57:36 GMT, Amos Shi <ashi at openjdk.org> wrote:
> Backport of [JDK-8263940](https://bugs.openjdk.org/browse/JDK-8263940)
> - This PR contains 2 commits
> - commit 1 - is the changed from `git apply`
> - commit 2 - is the manual merge based on the `ZipFile.java.rej` and `SetDefaultProvider.java.rej` files
> - We respect all the changes of the `.rej` files, and fixed Java 11 compile errors at the same time.
>
> - `git apply` log
>
> github.com/dev-8263940-11
> branch 'backport-8263940' set up to track 'origin/backport-8263940'.
> Switched to a new branch 'backport-8263940'
>
> patching file 'src/java.base/share/classes/java/util/zip/ZipFile.java'
> Reversed (or previously applied) patch detected! Assume -R? [y] y
> 2 out of 3 hunks failed--saving rejects to 'src/java.base/share/classes/java/util/zip/ZipFile.java.rej'
> patching file 'test/jdk/java/nio/file/spi/SetDefaultProvider.java'
> 1 out of 3 hunks failed--saving rejects to 'test/jdk/java/nio/file/spi/SetDefaultProvider.java.rej'
>
>
> - `git status` log
>
>
> modified: src/java.base/share/classes/java/util/zip/ZipFile.java
> modified: test/jdk/java/nio/file/spi/SetDefaultProvider.java
>
> Untracked files:
> src/java.base/share/classes/java/util/zip/ZipFile.java.rej
> test/jdk/java/nio/file/spi/SetDefaultProvider.java.rej
>
>
> - `git diff` on `src/java.base/share/classes/java/util/zip/ZipFile.java.rej`
>
>
> @@ -68,7 +69,6 @@
> import jdk.internal.ref.CleanerFactory;
> import jdk.internal.vm.annotation.Stable;
> import sun.nio.cs.UTF_8;
> -import sun.nio.fs.DefaultFileSystemProvider;
> import sun.security.util.SignatureFileVerifier;
>
> import static java.util.zip.ZipConstants64.*;
> @@ -1255,19 +1255,14 @@
> }
> }
> private static final HashMap<Key, Source> files = new HashMap<>();
> - /**
> - * Use the platform's default file system to avoid
> - * issues when the VM is configured to use a custom file system provider.
> - */
> - private static final java.nio.file.FileSystem builtInFS =
> - DefaultFileSystemProvider.theFileSystem();
> +
>
> static Source get(File file, boolean toDelete, ZipCoder zc) throws IOException {
> final Key key;
> try {
> key = new Key(file,
> - Files.readAttributes(builtInFS.getPath(file.getPath()),
> - BasicFileAttributes.class), zc);
> + Files.readAttributes(file.toPath(), BasicFileAttributes.class),
> + zc);
> } catch (InvalidPathException ipe) {
> ...
test/jdk/java/nio/file/spi/SetDefaultProvider.java line 108:
> 106: .filter(f -> f.startsWith("TestProvider"))
> 107: .collect(Collectors.toList());
> 108: for(var p : paths) {
Fix compile error on Java 11: the `toList()` does not work on 11
-------------
PR Review Comment: https://git.openjdk.org/jdk11u-dev/pull/2647#discussion_r1575226821
More information about the jdk-updates-dev
mailing list