Skip to content

Fix relative module resolution in fatjar URLs#2722

Merged
ChristianGruen merged 1 commit into
BaseXdb:mainfrom
GuntherRademacher:fatjar-url-resolution
Jul 15, 2026
Merged

Fix relative module resolution in fatjar URLs#2722
ChristianGruen merged 1 commit into
BaseXdb:mainfrom
GuntherRademacher:fatjar-url-resolution

Conversation

@GuntherRademacher

Copy link
Copy Markdown
Member

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) with URI.resolve:

return get(JARPREF + new URI(pth.substring(JARPREF.length())).resolve(path));

The problem: for a plain jar URL like jar:file:/a/b.jar!/…, stripping jar: leaves file:/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!/…. Stripping jar: leaves fatjar:WEB-INF/…, whose scheme-specific part doesn't start with /, making it an opaque URI. URI.resolve against an opaque base discards the base entirely and just returns the relative reference.

The old new URL(...) path never had this issue because the jar: 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.

@ChristianGruen
ChristianGruen merged commit 2455a01 into BaseXdb:main Jul 15, 2026
1 check passed
@ChristianGruen
ChristianGruen deleted the fatjar-url-resolution branch July 15, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants