RFR: 8372708: Javadoc ignores "-locale" and uses default locale for all messages and texts
Chen Liang
liach at openjdk.org
Tue Dec 2 16:17:09 UTC 2025
On Tue, 2 Dec 2025 14:05:10 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:
> Please review a simple change to make the JavaDoc `-locale` option work with English language locales when the system default is a non-English locale supported by JavaDoc. The problem is that root resource bundles such as `standard.properties` are not recognized as English, and [java.util.ResourceBundle][1] will use the system default locale as fallback before returning the root bundle.
>
> [1]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/ResourceBundle.html#default_behavior
>
> The solution is to provide empty English resource bundles that will use the root bundles as parents. An alternative would be to use a [ResourceBundleProvider][2], but I think the added complexity is not justified for this case. Also, we can't use [ResourceBundle.Control][3] in a named module.
>
> [2]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/spi/ResourceBundleProvider.html
> [3]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/ResourceBundle.Control.html#getNoFallbackControl(java.util.List)
>
> The test runs JavaDoc with all combinations of supported locales for default locale and `-locale` option, making sure the console output uses the default locale while generated docuentation adheres to the `-locale` option.
I assume things like `-locale jp` doesn't work right now in an English environment too, right?
-------------
Marked as reviewed by liach (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28603#pullrequestreview-3531003259
More information about the javadoc-dev
mailing list