RFR: 8271079: JavaFileObject#toUri and multi-release jars [v3]

Jonathan Gibbons jjg at openjdk.java.net
Fri Dec 10 16:40:19 UTC 2021

On Fri, 10 Dec 2021 08:16:46 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> Prior to this PR, `toUri()` of class `ZipPath` in module `jdk.zipfs` and class `PathFileObject` in module `jdk.compiler` were always composed by base path names. Even for versioned entries of a multi-release JAR file.
>> Now, a `URI` for an entry is composed of its real path names using an existing lookup function in the associated zip file system object.
>> This PR also removes a superseded work around for [JDK-8134451](https://bugs.openjdk.java.net/browse/JDK-8134451).
>> Fixes https://bugs.openjdk.java.net/browse/JDK-8271079
> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
>   Turn `getRealPath()` into a no-arg helper method

javac changes look good. I suggest adding this bug number to the test to check that URIs are not double-encoded.

src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java line 183:

> 181:         @Override @DefinedBy(Api.COMPILER)
> 182:         public URI toUri() {
> 183:             // Work around bug JDK-8134451:

Nice to see the workaround go.  
Find the test that was added at the time of the workaround, and add this bug number (8271079) to the `@bug` line in that test, to mark that test as relevant to this issue.

test/langtools/tools/javac/T8271079.java line 39:

> 37: import java.util.*;
> 38: import java.util.jar.JarEntry;
> 39: import javax.tools.*;

You could add an explicit `import java.util.spi.ToolProvider;` to remove the need for qualified names in the code

test/langtools/tools/javac/T8271079.java line 58:

> 56:             testT8271079(mr);
> 57:         } finally {
> 58:             Files.deleteIfExists(mr);

If you generate files in the test's current directory, it's not wrong to delete them but there's no need either, and you might be deleting useful debug evidence if the test fails.


Marked as reviewed by jjg (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6768

More information about the compiler-dev mailing list