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.

-------------

Commit messages:
 - 8372708: Javadoc ignores "-locale" and uses default locale for all messages 
and texts

Changes: https://git.openjdk.org/jdk/pull/28603/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28603&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8372708
  Stats: 162 lines in 3 files changed: 162 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/28603.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28603/head:pull/28603

PR: https://git.openjdk.org/jdk/pull/28603

Reply via email to