RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

XenoAmess duke at openjdk.java.net
Thu Mar 10 16:18:45 UTC 2022


On Thu, 10 Mar 2022 16:13:42 GMT, XenoAmess <duke at openjdk.java.net> wrote:

>> 8281631: HashMap copy constructor and putAll can over-allocate table
>
> XenoAmess has updated the pull request incrementally with five additional commits since the last revision:
> 
>  - clean out tests
>  - Remove 'randomness' keyword.
>  - Cleanup and commenting.
>  - initial rewrite of WhiteBoxResizeTest
>  - Restore WhiteBoxResizeTest.java

test/jdk/java/util/HashMap/WhiteBoxResizeTest.java line 116:

> 114:     }
> 115: 
> 116:     void putN(Map<Integer, Integer> map, int n) {

@stuart-marks well we know this is correct for WeakHashMap when n < IntegerCache.high because we have Integer constant pool, but I think it be better to manlly make it sure it is referenced, as IntegerCache.high is configurable.

test/jdk/java/util/HashMap/WhiteBoxResizeTest.java line 290:

> 288:         cases.addAll(genPopulatedCapacityCases(12,  16));
> 289:         cases.addAll(genPopulatedCapacityCases(13,  32));
> 290:         cases.addAll(genPopulatedCapacityCases(64, 128));

@stuart-marks should there better be a loop from 1 to 64?

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

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


More information about the core-libs-dev mailing list