RFR 8200788 : Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
paul.sandoz at oracle.com
Thu Apr 5 22:25:38 UTC 2018
> On Apr 5, 2018, at 12:04 AM, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
> 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.
Thanks for fixing this.
I suspect that code and comment were written when there were fewer access modes.
> 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