Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8282444: Module finder incorrectly assumes default file system path-s…
…eparator character

Reviewed-by: alanb
  • Loading branch information
ChrisHegarty committed Mar 1, 2022
1 parent d4d12ad commit 369291b
Show file tree
Hide file tree
Showing 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
Expand Down Expand Up @@ -662,11 +662,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 @@ -737,7 +738,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 @@ -751,7 +752,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

12 comments on commit 369291b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ritzow
Copy link

@ritzow ritzow commented on 369291b Mar 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ritzow, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user ritzow for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

@ChrisHegarty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on 369291b Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisHegarty Could not automatically backport 369291b2 to openjdk/jdk17u due to conflicts in the following files:

  • src/java.base/share/classes/jdk/internal/module/ModulePath.java

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk17u:

$ git checkout -b ChrisHegarty-backport-369291b2
$ git fetch --no-tags https://git.openjdk.java.net/jdk 369291b265e13d625c5f465da9b1854c0d70c435
$ git cherry-pick --no-commit 369291b265e13d625c5f465da9b1854c0d70c435
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 369291b265e13d625c5f465da9b1854c0d70c435'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u with the title Backport 369291b265e13d625c5f465da9b1854c0d70c435.

@ChrisHegarty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on 369291b Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisHegarty Could not automatically backport 369291b2 to openjdk/jdk17u due to conflicts in the following files:

  • src/java.base/share/classes/jdk/internal/module/ModulePath.java

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk17u:

$ git checkout -b ChrisHegarty-backport-369291b2
$ git fetch --no-tags https://git.openjdk.java.net/jdk 369291b265e13d625c5f465da9b1854c0d70c435
$ git cherry-pick --no-commit 369291b265e13d625c5f465da9b1854c0d70c435
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 369291b265e13d625c5f465da9b1854c0d70c435'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u with the title Backport 369291b265e13d625c5f465da9b1854c0d70c435.

@ChrisHegarty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk18u

@openjdk
Copy link

@openjdk openjdk bot commented on 369291b Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisHegarty Could not automatically backport 369291b2 to openjdk/jdk18u due to conflicts in the following files:

  • src/java.base/share/classes/jdk/internal/module/ModulePath.java

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk18u:

$ git checkout -b ChrisHegarty-backport-369291b2
$ git fetch --no-tags https://git.openjdk.java.net/jdk 369291b265e13d625c5f465da9b1854c0d70c435
$ git cherry-pick --no-commit 369291b265e13d625c5f465da9b1854c0d70c435
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 369291b265e13d625c5f465da9b1854c0d70c435'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk18u with the title Backport 369291b265e13d625c5f465da9b1854c0d70c435.

@ChrisHegarty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport 17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 369291b Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisHegarty The target repository 17u-dev is not a valid target for backports.
List of valid target repositories: openjdk/jdk11u, openjdk/jdk11u-dev, openjdk/jdk12u, openjdk/jdk13u, openjdk/jdk13u-dev, openjdk/jdk14u, openjdk/jdk15u, openjdk/jdk15u-dev, openjdk/jdk16u, openjdk/jdk17u, openjdk/jdk17u-dev, openjdk/jdk18, openjdk/jdk18u, openjdk/jdk7u, openjdk/jdk8u-dev.
Supplying the organization/group prefix is optional.

@ChrisHegarty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport openjdk/jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 369291b Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisHegarty Could not automatically backport 369291b2 to openjdk/jdk17u-dev due to conflicts in the following files:

  • src/java.base/share/classes/jdk/internal/module/ModulePath.java

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk17u-dev:

$ git checkout -b ChrisHegarty-backport-369291b2
$ git fetch --no-tags https://git.openjdk.java.net/jdk 369291b265e13d625c5f465da9b1854c0d70c435
$ git cherry-pick --no-commit 369291b265e13d625c5f465da9b1854c0d70c435
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 369291b265e13d625c5f465da9b1854c0d70c435'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport 369291b265e13d625c5f465da9b1854c0d70c435.

Please sign in to comment.