RFR 8200788 : Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode

Ivan Gerasimov ivan.gerasimov at oracle.com
Thu Apr 5 07:04:56 UTC 2018


Hello!

Yet another HashMap that can be preallocated more accurately.

Currently, the map is created as the following:
             // Initial capacity of # values is sufficient to avoid resizes
             // for the smallest table size (32)
             methodNameToAccessMode = new 
HashMap<>(AccessMode.values().length);

Even though the comment suggests that no resizes of the table should 
occur, in fact the threshold is calculated as 32 * 0.75 = 24, so when 
24th element is inserted then the internal storage is reallocated and 
the content of the table is reinserted.

Also, a missing @modules line is added to the regression test that was 
pushed with the fix for JDK-8200696.

Would you please help review this?

BUGURL: https://bugs.openjdk.java.net/browse/JDK-8200788
WEBREV: http://cr.openjdk.java.net/~igerasim/8200788/00/webrev/

-- 
With kind regards,
Ivan Gerasimov



More information about the core-libs-dev mailing list