Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8282444: Module finder incorrectly assumes default file system path-separator character #266

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, 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
Expand Down Expand Up @@ -663,11 +663,12 @@ private ModuleReference readJar(Path file) throws IOException {
// -- 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) {
Expand Down Expand Up @@ -738,7 +739,7 @@ private Optional<String> toPackageName(String name) {
* @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();
Expand All @@ -752,7 +753,7 @@ private Optional<String> toPackageName(Path file) {
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 {
Expand Down
@@ -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
Expand All @@ -23,6 +23,7 @@

/**
* @test
* @bug 8178380 8282444
* @modules jdk.zipfs
* @library /test/lib
* @build ModulesInCustomFileSystem m1/* m2/*
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/java/lang/module/customfs/m1/p/Main.java
Expand Up @@ -25,6 +25,6 @@

public class Main {
public static void main(String[] args) {
q.Hello.hello();
q.r.Hello.hello();
}
}
2 changes: 1 addition & 1 deletion test/jdk/java/lang/module/customfs/m2/module-info.java
Expand Up @@ -22,5 +22,5 @@
*/

module m2 {
exports q;
exports q.r;
}
Expand Up @@ -21,7 +21,7 @@
* questions.
*/

package q;
package q.r;

public class Hello {
public static void hello() {
Expand Down