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

fix broken JRT URL handling for JDK >= 13 #304

Merged

Conversation

codecholeric
Copy link
Collaborator

With JDK 13 some wrongly implemented behavior of JRT path handling was fixed. I.e. by JEP-220 (https://openjdk.java.net/jeps/220) while URIs possess the shape of jrt:/module.name/some/clazz/Name.class the respective (virtual) file system path for JRTs supposedly has the shape of /modules/module.name/some/clazz/Name.class. Unfortunately ArchUnit was relying on the wrongly implemented version of JrtFileSystemProvider which would return a path for JRTs of /module.name/some/clazz/Name.class. Thus with JDK >= 13 the URI handling for JRTs was broken.
This will now be fixed by relying on pure JRT URI handling without relying on conversion to java.nio.file.Path. We simply split the path of a JRT URI on / and treat the first segment as module name, the rest of the segments as the resource/class name (e.g. module.name and some/clazz/Name.class). Note that we unfortunately cannot use URI.getPath() within NormalizedUri to retrieve the path without the schema, since URI.getPath() will return null for JAR URIs (i.e. jar:file:/...).

Resolves: #303

With JDK 13 some wrongly implemented behavior of JRT path handling was fixed. I.e. by JEP-220 (https://openjdk.java.net/jeps/220) while URIs possess the shape of `jrt:/module.name/some/clazz/Name.class` the respective (virtual) file system path for JRTs supposedly has the shape of `/modules/module.name/some/clazz/Name.class`. Unfortunately ArchUnit was relying on the wrongly implemented version of `JrtFileSystemProvider` which would return a path for JRTs of `/module.name/some/clazz/Name.class`. Thus with JDK >= 13 the URI handling for JRTs was broken.
This will now be fixed by relying on pure JRT URI handling without relying on conversion to `java.nio.file.Path`. We simply split the path of a JRT URI on `/` and treat the first segment as module name, the rest of the segments as the resource/class name (e.g. `module.name` and `some/clazz/Name.class`). Note that we unfortunately cannot use `URI.getPath()` within `NormalizedUri` to retrieve the path without the schema, since `URI.getPath()` will return `null` for JAR URIs (i.e. `jar:file:/...`).

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
@codecholeric codecholeric self-assigned this Jan 31, 2020
@ghost
Copy link

ghost commented Jan 31, 2020

DeepCode's analysis on #852c80 found:

  • 0 critical issues. ⚠️ 0 warnings and 0 minor issues. ✔️ 0 issues were fixed.

💬 This comment has been generated by the DeepCode bot, installed by the owner of the repository. The DeepCode bot protects your repository by detecting and commenting on security vulnerabilities or other critical issues.


☺️ If you want to provide feedback on our bot, here is how to contact us.

@codecholeric codecholeric merged commit 51087d5 into release-0.13.1 Jan 31, 2020
@codecholeric codecholeric deleted the bugfix/fix-jdk13-module-name-resolution branch January 31, 2020 19:16
codecholeric added a commit that referenced this pull request Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant