RFR: 8348351: Improve lazy initialization of the available currencies set

Chen Liang liach at openjdk.org
Thu May 8 23:10:52 UTC 2025


On Thu, 8 May 2025 22:55:34 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR which stems from discussion in the PR of JDK-8347949.
> 
> The set of lazily loaded Currencies is a good fit for stable values. `available` can now be made final as it is a SV supplier.
> 
> (This change also includes an unrelated minor edit to comments in `Currency::getCurrencies` to make the distinction for simple vs special Currencies.)

src/java.base/share/classes/java/util/Currency.java line 471:

> 469: 
> 470:     // Builds and returns the set of available Currencies
> 471:     private static HashSet<Currency> getCurrencies() {

I think we should rename this to `computeCurrencies` or `makeCurrencies` to indicate we are creating a new instance.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25134#discussion_r2080606583


More information about the core-libs-dev mailing list