Skip to content

Embed all locales via -H:+IncludeAllLocales - #48

Merged
delphyne merged 1 commit into
mainfrom
fix/graalvm-include-all-locales
Oct 7, 2026
Merged

delphyne merged 1 commit into
mainfrom
fix/graalvm-include-all-locales

Conversation

@delphyne

@delphyne delphyne commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#42 added -H:IncludeLocales= (empty value) intending to embed all locales, but on GraalVM that value doesn't mean "all".
The empty string is parsed as a single language tag; only -H:+IncludeAllLocales adds every available locale.
The resulting image is identical to one built with no locale flag, so the Linux release binaries most likely still abort at startup in protobuf-java's RuntimeVersion.<clinit>:

MissingReflectionRegistrationError: sun.text.resources.cldr.FormatData_en_US

Fix: switch to -H:+IncludeAllLocales.
It isn't deprecated, either on GraalVM 21.0.2 (what CI uses) or on current GraalVM master; the deprecated option there is -H:DefaultLocale.

The trade-off is size: roughly +22MB per binary.

Verification

Reproduced with protoc-gen-markdown, which has the same protobuf-java path and native-image flags.
The failure only shows up on Linux builds where the builder locale is C.UTF-8, as on the GitHub runners.
macOS builds start fine regardless, which is why the macOS verification in #42 passed.

Built in a ghcr.io/graalvm/native-image-community:21.0.2 container with LANG=C.UTF-8, then ran each binary in debian:stable-slim under C.UTF-8, en_US, de_DE, ja_JP and ar_SA:

Build flag Result
none crashes under all 5 locales (FormatData_en_US)
-H:IncludeLocales= crashes under all 5 (same image as no flag)
-H:+IncludeAllLocales starts cleanly under all 5

Companion PRs: engine-public/protoc-gen-markdown#17 and engine-public/protoc-gen-mermaid#14.

Test plan

  • Linux release binary of protoc-gen-openapi starts without MissingReflectionRegistrationError

🤖 Generated with Claude Code

`-H:IncludeLocales=` with an empty value does not mean "all locales" on
GraalVM 21.0.2 (or current master): the empty string is parsed as a single
language tag, and only `-H:+IncludeAllLocales` adds every available locale.
The resulting image is the same as one built with no locale flag at all, so
the Linux release binaries still abort in protobuf-java's
`RuntimeVersion.<clinit>` with:

  MissingReflectionRegistrationError: sun.text.resources.cldr.FormatData_en_US

Reproduced with protoc-gen-markdown (same protobuf-java path and flags)
built in a GraalVM CE 21.0.2 Linux container with LANG=C.UTF-8, matching the
GitHub runners: no flag and `-H:IncludeLocales=` both crash under every
runtime locale tested; `-H:+IncludeAllLocales` starts cleanly under
C.UTF-8, en_US, de_DE, ja_JP and ar_SA. macOS builds don't reproduce the
failure at all, which is why the earlier local verification passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@delphyne
delphyne requested a review from a team October 7, 2026 15:20
@delphyne
delphyne merged commit e16160c into main Oct 7, 2026
4 checks passed
@delphyne
delphyne deleted the fix/graalvm-include-all-locales branch October 7, 2026 21:17
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.

1 participant