fix broken JRT URL handling for JDK >= 13 #304
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofJrtFileSystemProvider
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
andsome/clazz/Name.class
). Note that we unfortunately cannot useURI.getPath()
withinNormalizedUri
to retrieve the path without the schema, sinceURI.getPath()
will returnnull
for JAR URIs (i.e.jar:file:/...
).Resolves: #303