Skip to content

Do not percent-encode '+' in classpath-jar manifest Class-Path entries#522

Closed
mgalindo-sc wants to merge 1 commit into
bazelbuild:mainfrom
mgalindo-sc:mgalindo-classpath-jar-no-plus-encoding-upstream
Closed

Do not percent-encode '+' in classpath-jar manifest Class-Path entries#522
mgalindo-sc wants to merge 1 commit into
bazelbuild:mainfrom
mgalindo-sc:mgalindo-classpath-jar-no-plus-encoding-upstream

Conversation

@mgalindo-sc

Copy link
Copy Markdown
Contributor

Add '+' to the allowed character class so it passes through literally.

The java stub template packs over-long classpaths into a classpath jar whose manifest Class-Path entries percent-encode any character outside [-_.~/a-zA-Z0-9]. Bzlmod canonical repository names put '+' into every external-repo classpath entry, so those entries now contain "%2b" sequences. '+' is a valid URI path character and needs no encoding, and the "%2b" breaks consumers that pass classpath URLs through printf-style formatting

The java stub template packs over-long classpaths into a classpath jar
whose manifest Class-Path entries percent-encode any character outside
[-_.~/a-zA-Z0-9]. Bzlmod canonical repository names put '+' into every
external-repo classpath entry, so those entries now contain "%2b"
sequences. '+' is a valid URI path character and needs no encoding, and
the "%2b" breaks consumers that pass classpath URLs through printf-style
formatting: Robolectric's Logger.info() treats its message as a format
string, so its native runtime loader throws MissingFormatArgumentException
on "%2b" while logging the library URL, the load aborts, and every
SQLite-backed android_local_test fails with UnsatisfiedLinkError on
SQLiteConnectionNatives.nativeOpen.

Add '+' to the allowed character class so it passes through literally.
@ted-xie

ted-xie commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

I'd suggest discussing this change with the rules_java folks first; that's where this repo's stub template is copied from.

See https://github.com/bazelbuild/rules_java/blob/1f215f8ca1c459e4c564f6c9b3f88d1cfa7a113a/java/bazel/rules/java_stub_template.txt#L16.

@mgalindo-sc

Copy link
Copy Markdown
Contributor Author

I'd suggest discussing this change with the rules_java folks first; that's where this repo's stub template is copied from.

See https://github.com/bazelbuild/rules_java/blob/1f215f8ca1c459e4c564f6c9b3f88d1cfa7a113a/java/bazel/rules/java_stub_template.txt#L16.

PR in rules_java bazelbuild/rules_java#358

@Bencodes

Copy link
Copy Markdown
Contributor

This made it into the upstream rules_java bazelbuild/rules_java#358

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.

3 participants