Skip to content

Embed en-US CLDR data in native image - #42

Open
delphyne wants to merge 1 commit into
mainfrom
fix/graalvm-include-locales-en-us
Open

Embed en-US CLDR data in native image#42
delphyne wants to merge 1 commit into
mainfrom
fix/graalvm-include-locales-en-us

Conversation

@delphyne

Copy link
Copy Markdown
Contributor

Summary

Mirrors https://github.com/engine-public/protoc-gen-markdown/pull/17. Once protoc-gen-openapi v1.0.0 is invoked as a protoc plugin, its GraalVM-native binary aborts at startup:

Exception in thread "main" org.graalvm.nativeimage.MissingReflectionRegistrationError:
The program tried to reflectively access class sun.text.resources.cldr.FormatData_en_US
without it being registered for runtime reflection.

protobuf-java's RuntimeVersion.<clinit> calls String.format when building its runtime version string, which routes through DecimalFormatSymbols.getInstanceLocaleData.getBundleClass.forName("sun.text.resources.cldr.FormatData_en_US"). resources.autodetect() does not embed JDK CLDR bundles, and -H:ThrowMissingRegistrationErrors= (empty value = throw on any missing) makes the lookup fatal.

Fix: add -H:IncludeLocales=en-US so the en-US CLDR bundle is baked into the binary.

Companion PRs against the sibling plugins:

Observed via the staging PR https://github.com/HotelEngine/engine-partner-api-staging/pull/106 which pins all three engine protoc plugins to Maven Central releases. The build died on protoc-gen-markdown first (alphabetical plugin invocation order) so openapi has not yet been observed failing in the wild — but the same static-init path exists and will fail the same way as soon as it is exercised.

Test plan

  • ./gradlew nativeCompile produces a binary that starts without the MissingReflectionRegistrationError
  • Downstream engine-partner-api-staging PR consumes the follow-up release and its :engine-partner-api-service:generateProto succeeds

🤖 Generated with Claude Code

Mirrors the fix landed on `protoc-gen-markdown`. The native binary aborts
at startup with:

  MissingReflectionRegistrationError: sun.text.resources.cldr.FormatData_en_US

protobuf-java's `RuntimeVersion.<clinit>` calls `String.format` when
building its version string, which routes through
`DecimalFormatSymbols.getInstance` → `LocaleData.getBundle` →
`Class.forName("sun.text.resources.cldr.FormatData_en_US")`. With
`-H:ThrowMissingRegistrationErrors=` set and no CLDR data embedded, the
lookup is fatal.

Add `-H:IncludeLocales=en-US` so the en-US bundle is baked in.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@delphyne
delphyne requested a review from a team July 27, 2026 18:20
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