<i18n dev> RFR: 8186958: Need method to create pre-sized HashMap [v18]

Stuart Marks smarks at openjdk.java.net
Wed Apr 13 23:29:19 UTC 2022


On Wed, 13 Apr 2022 22:20:14 GMT, XenoAmess <duke at openjdk.java.net> wrote:

>> 8186958: Need method to create pre-sized HashMap
>
> XenoAmess has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update LastModified

src/java.base/unix/classes/java/lang/ProcessEnvironment.java line 102:

> 100:     /* Only for use by Runtime.exec(...String[]envp...) */
> 101:     static Map<String,String> emptyEnvironment(int capacity) {
> 102:         return new StringEnvironment(HashMap.newHashMap(capacity));

This change is correct, since this is called with the length of an array that's used to populate the environment. It really should be named `size` instead of `capacity`. However the windows version of this code simply calls `super(capacity)` as it's a subclass of `HashMap`, which is wrong. Well, probably not worth changing this now. We may need to revisit this later to do some cleaning up. (And also the strange computation in the static initializer at line 71.)

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

PR: https://git.openjdk.java.net/jdk/pull/7928


More information about the i18n-dev mailing list