Fix relative module resolution in fatjar URLs#2722
Merged
ChristianGruen merged 1 commit intoJul 15, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The changes that were done in the context of moving on to Java 21 brought up a regression in the code that supports fatjar loading (originally added in #2154). Commit 2d905d8 replaced the deprecated
new URL(new URL(pth), path)withURI.resolve:The problem: for a plain jar URL like
jar:file:/a/b.jar!/…, strippingjar:leavesfile:/a/b.jar!/…, which is a hierarchical URI, so resolve merges paths correctly. But a fatjar URL nests a custom scheme -jar:fatjar:WEB-INF/lib/rr.jar!/…. Strippingjar:leavesfatjar:WEB-INF/…, whose scheme-specific part doesn't start with/, making it an opaque URI.URI.resolveagainst an opaque base discards the base entirely and just returns the relative reference.The old
new URL(...)path never had this issue because thejar:URL handler splits at!/and resolves only the entry.Consequently the fix is to check for the presence of
!/, keep the jar-location prefix (jar:…!/) intact and resolve the relative reference only against the entry path, which is always hierarchical.