8267583: jmod fails on symlink to class file
Reviewed-by: alanb
This commit is contained in:
parent
083416d36c
commit
bf8d4a8eca
@ -674,7 +674,8 @@ public class JmodTask {
|
|||||||
Set<String> findPackages(Path dir) {
|
Set<String> findPackages(Path dir) {
|
||||||
try {
|
try {
|
||||||
return Files.find(dir, Integer.MAX_VALUE,
|
return Files.find(dir, Integer.MAX_VALUE,
|
||||||
((path, attrs) -> attrs.isRegularFile()))
|
((path, attrs) -> attrs.isRegularFile()),
|
||||||
|
FileVisitOption.FOLLOW_LINKS)
|
||||||
.map(dir::relativize)
|
.map(dir::relativize)
|
||||||
.filter(path -> isResource(path.toString()))
|
.filter(path -> isResource(path.toString()))
|
||||||
.map(path -> toPackageName(path))
|
.map(path -> toPackageName(path))
|
||||||
|
@ -98,7 +98,7 @@ public class JmodTest {
|
|||||||
|
|
||||||
// JDK-8166286 - jmod fails on symlink to directory
|
// JDK-8166286 - jmod fails on symlink to directory
|
||||||
@Test
|
@Test
|
||||||
public void testSymlinks() throws IOException {
|
public void testDirSymlinks() throws IOException {
|
||||||
Path apaDir = EXPLODED_DIR.resolve("apa");
|
Path apaDir = EXPLODED_DIR.resolve("apa");
|
||||||
Path classesDir = EXPLODED_DIR.resolve("apa").resolve("classes");
|
Path classesDir = EXPLODED_DIR.resolve("apa").resolve("classes");
|
||||||
assertTrue(compileModule("apa", classesDir));
|
assertTrue(compileModule("apa", classesDir));
|
||||||
@ -110,6 +110,8 @@ public class JmodTest {
|
|||||||
assertTrue(Files.exists(link));
|
assertTrue(Files.exists(link));
|
||||||
} catch (IOException|UnsupportedOperationException uoe) {
|
} catch (IOException|UnsupportedOperationException uoe) {
|
||||||
// OS does not support symlinks. Nothing to test!
|
// OS does not support symlinks. Nothing to test!
|
||||||
|
System.out.println("Creating symlink failed. Test passes vacuously.");
|
||||||
|
uoe.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +121,42 @@ public class JmodTest {
|
|||||||
"--class-path", classesDir.toString(),
|
"--class-path", classesDir.toString(),
|
||||||
jmod.toString())
|
jmod.toString())
|
||||||
.assertSuccess();
|
.assertSuccess();
|
||||||
|
Files.delete(jmod);
|
||||||
|
}
|
||||||
|
|
||||||
|
// JDK-8267583 - jmod fails on symlink to class file
|
||||||
|
@Test
|
||||||
|
public void testFileSymlinks() throws IOException {
|
||||||
|
Path apaDir = EXPLODED_DIR.resolve("apa");
|
||||||
|
Path classesDir = EXPLODED_DIR.resolve("apa").resolve("classes");
|
||||||
|
assertTrue(compileModule("apa", classesDir));
|
||||||
|
|
||||||
|
Files.move(classesDir.resolve("module-info.class"),
|
||||||
|
classesDir.resolve("module-info.class1"));
|
||||||
|
Files.move(classesDir.resolve(Paths.get("jdk", "test", "apa", "Apa.class")),
|
||||||
|
classesDir.resolve("Apa.class1"));
|
||||||
|
try {
|
||||||
|
Path link = Files.createSymbolicLink(
|
||||||
|
classesDir.resolve("module-info.class"),
|
||||||
|
classesDir.resolve("module-info.class1").toAbsolutePath());
|
||||||
|
assertTrue(Files.exists(link));
|
||||||
|
link = Files.createSymbolicLink(
|
||||||
|
classesDir.resolve(Paths.get("jdk", "test", "apa", "Apa.class")),
|
||||||
|
classesDir.resolve("Apa.class1").toAbsolutePath());
|
||||||
|
assertTrue(Files.exists(link));
|
||||||
|
} catch (IOException|UnsupportedOperationException uoe) {
|
||||||
|
// OS does not support symlinks. Nothing to test!
|
||||||
|
System.out.println("Creating symlinks failed. Test passes vacuously.");
|
||||||
|
uoe.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Path jmod = MODS_DIR.resolve("apa.jmod");
|
||||||
|
jmod("create",
|
||||||
|
"--class-path", classesDir.toString(),
|
||||||
|
jmod.toString())
|
||||||
|
.assertSuccess();
|
||||||
|
Files.delete(jmod);
|
||||||
}
|
}
|
||||||
|
|
||||||
// JDK-8170618 - jmod should validate if any exported or open package is missing
|
// JDK-8170618 - jmod should validate if any exported or open package is missing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user