Skip to content

Commit

Permalink
8253761: Wrong URI syntax printed by jar --describe-module
Browse files Browse the repository at this point in the history
Reviewed-by: alanb
  • Loading branch information
sormuras authored and Alan Bateman committed Oct 5, 2020
1 parent b29e108 commit f2f77f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/jdk.jartool/share/classes/sun/tools/jar/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ static class ZipFileModuleInfoEntry implements ModuleInfoEntry {
/** Returns an optional containing the effective URI. */
@Override public Optional<String> uriString() {
String uri = (Paths.get(zipFile.getName())).toUri().toString();
uri = "jar:" + uri + "/!" + entry.getName();
uri = "jar:" + uri + "!/" + entry.getName();
return Optional.of(uri);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/jdk/tools/jar/mmrjar/Basic.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void test5() throws IOException {
jar("-d --file mr.jar");

String uri = (Paths.get("mr.jar")).toUri().toString();
uri = "jar:" + uri + "/!module-info.class";
uri = "jar:" + uri + "!/module-info.class";

actual = lines(outbytes);
expected = Set.of(
Expand Down Expand Up @@ -423,7 +423,7 @@ public void test7() throws IOException {
actual = lines(outbytes);
expected = Set.of(
"releases: 9 10",
"m1 " + uriPrefix + "/!META-INF/versions/9/module-info.class",
"m1 " + uriPrefix + "!/META-INF/versions/9/module-info.class",
"requires java.base mandated",
"exports p",
"main-class p.Main"
Expand All @@ -434,7 +434,7 @@ public void test7() throws IOException {
actual = lines(outbytes);
expected = Set.of(
"releases: 9 10",
"m1 " + uriPrefix + "/!META-INF/versions/10/module-info.class",
"m1 " + uriPrefix + "!/META-INF/versions/10/module-info.class",
"requires java.base mandated",
"exports p",
"main-class p.Main"
Expand Down
12 changes: 8 additions & 4 deletions test/jdk/tools/jar/modularJar/Basic.java
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ public void partialUpdateFooModuleInfo() throws IOException {
"--file=" + modularJar.toString())
.assertSuccess()
.resultChecker(r -> {
// Expect "bar jar:file:/.../!module-info.class"
// Expect "bar jar:file:/...!/module-info.class"
// conceals jdk.test.foo, conceals jdk.test.foo.internal"
String uri = "jar:" + modularJar.toUri().toString() + "/!module-info.class";
String uri = "jar:" + modularJar.toUri().toString() + "!/module-info.class";
assertTrue(r.output.contains("bar " + uri),
"Expecting to find \"bar " + uri + "\"",
"in output, but did not: [" + r.output + "]");
Expand Down Expand Up @@ -848,10 +848,14 @@ public void describeModuleFoo() throws IOException {
jar(option,
"--file=" + modularJar.toString())
.assertSuccess()
.resultChecker(r ->
.resultChecker(r -> {
assertTrue(r.output.contains(FOO.moduleName + "@" + FOO.version),
"Expected to find ", FOO.moduleName + "@" + FOO.version,
" in [", r.output, "]")
" in [", r.output, "]");
assertTrue(r.output.contains(modularJar.toUri().toString()),
"Expected to find ", modularJar.toUri().toString(),
" in [", r.output, "]");
}
);

jar(option,
Expand Down

1 comment on commit f2f77f7

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on f2f77f7 Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.