8282444: Module finder incorrectly assumes default file system path-separator character
Reviewed-by: alanb
This commit is contained in:
parent
d4d12ad1d9
commit
369291b265
src/java.base/share/classes/jdk/internal/module
test/jdk/java/lang/module/customfs
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -662,11 +662,12 @@ public class ModulePath implements ModuleFinder {
|
||||
// -- exploded directories --
|
||||
|
||||
private Set<String> explodedPackages(Path dir) {
|
||||
String separator = dir.getFileSystem().getSeparator();
|
||||
try {
|
||||
return Files.find(dir, Integer.MAX_VALUE,
|
||||
((path, attrs) -> attrs.isRegularFile() && !isHidden(path)))
|
||||
.map(path -> dir.relativize(path))
|
||||
.map(this::toPackageName)
|
||||
.map(path -> toPackageName(path, separator))
|
||||
.flatMap(Optional::stream)
|
||||
.collect(Collectors.toSet());
|
||||
} catch (IOException x) {
|
||||
@ -737,7 +738,7 @@ public class ModulePath implements ModuleFinder {
|
||||
* @throws InvalidModuleDescriptorException if the name is a class file in
|
||||
* the top-level directory (and it's not module-info.class)
|
||||
*/
|
||||
private Optional<String> toPackageName(Path file) {
|
||||
private Optional<String> toPackageName(Path file, String separator) {
|
||||
assert file.getRoot() == null;
|
||||
|
||||
Path parent = file.getParent();
|
||||
@ -751,7 +752,7 @@ public class ModulePath implements ModuleFinder {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
String pn = parent.toString().replace(File.separatorChar, '.');
|
||||
String pn = parent.toString().replace(separator, ".");
|
||||
if (Checks.isPackageName(pn)) {
|
||||
return Optional.of(pn);
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8178380 8282444
|
||||
* @modules jdk.zipfs
|
||||
* @library /test/lib
|
||||
* @build ModulesInCustomFileSystem m1/* m2/*
|
||||
|
@ -25,6 +25,6 @@ package p;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
q.Hello.hello();
|
||||
q.r.Hello.hello();
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,5 @@
|
||||
*/
|
||||
|
||||
module m2 {
|
||||
exports q;
|
||||
exports q.r;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package q;
|
||||
package q.r;
|
||||
|
||||
public class Hello {
|
||||
public static void hello() {
|
Loading…
x
Reference in New Issue
Block a user