Skip to content

Commit a29949b

Browse files
cushonPaul Hohensee
authored andcommitted
8214026: Canonicalized archive paths appearing in diagnostics
Backport-of: bddbbd8
1 parent 538013a commit a29949b

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ synchronized Container getContainer(Path path) throws IOException {
313313
fs = new DirectoryContainer(realPath);
314314
} else {
315315
try {
316-
fs = new ArchiveContainer(realPath);
316+
fs = new ArchiveContainer(path);
317317
} catch (ProviderNotFoundException | SecurityException ex) {
318318
throw new IOException(ex);
319319
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright (c) 2018, Google LLC. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8181897
27+
* @summary
28+
* @library /tools/lib
29+
* @modules jdk.compiler/com.sun.tools.javac.api
30+
* jdk.compiler/com.sun.tools.javac.main
31+
* jdk.jdeps/com.sun.tools.classfile
32+
* @build toolbox.JavacTask toolbox.TestRunner toolbox.ToolBox
33+
* @run main SymLinkArchiveTest
34+
*/
35+
36+
import java.nio.file.Files;
37+
import java.nio.file.Path;
38+
import java.nio.file.Paths;
39+
import java.util.jar.JarEntry;
40+
import java.util.jar.JarOutputStream;
41+
import toolbox.JavacTask;
42+
import toolbox.Task.Expect;
43+
import toolbox.Task.OutputKind;
44+
import toolbox.Task.Result;
45+
import toolbox.TestRunner;
46+
import toolbox.TestRunner.Test;
47+
import toolbox.ToolBox;
48+
49+
public class SymLinkArchiveTest extends TestRunner {
50+
public static void main(String... args) throws Exception {
51+
new SymLinkArchiveTest().runTests(m -> new Object[] {Paths.get(m.getName())});
52+
}
53+
54+
private final ToolBox tb = new ToolBox();
55+
56+
public SymLinkArchiveTest() {
57+
super(System.err);
58+
}
59+
60+
@Test
61+
public void testJarSymlink(Path base) throws Exception {
62+
Files.createDirectories(base);
63+
Path classpath = base.resolve("CLASSPATH");
64+
try (JarOutputStream jos = new JarOutputStream(Files.newOutputStream(classpath))) {
65+
jos.putNextEntry(new JarEntry("p/B.class"));
66+
jos.write(new byte[10]);
67+
}
68+
Path javaFile = base.resolve("T.java");
69+
tb.writeFile(javaFile, "class T extends p.B {}");
70+
71+
Path jar = base.resolve("lib.jar");
72+
Files.createSymbolicLink(jar, classpath.getFileName());
73+
74+
Result result = new JavacTask(tb).files(javaFile).classpath(jar).run(Expect.FAIL);
75+
String output = result.getOutput(OutputKind.DIRECT);
76+
77+
String expected = jar + "(/p/B.class)";
78+
if (!output.contains(expected)) {
79+
throw new AssertionError(
80+
"expected output to contain: " + expected + "\nwas:\n" + output);
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)