mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8282444: Module finder incorrectly assumes default file system path-separator character
Reviewed-by: alanb
This commit is contained in:
parent
d4d12ad1d9
commit
369291b265
5 changed files with 10 additions and 8 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue