RFR (XXS) 8080535: (ch) Expected size of Character.UnicodeBlock.map is not optimal

Paul Sandoz paul.sandoz at oracle.com
Wed May 20 09:04:15 UTC 2015


On May 19, 2015, at 9:40 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:

> Hi everyone!
> 
> What about this variant:
> http://cr.openjdk.java.net/~igerasim/8080535/02/webrev/
> 

  45         int mapSize = map.size();

Not used.


  49         int INITIAL_CAPACITY = 680; //(int)(510 / 0.75f + 1.0f);

Change to lower case.


Just had an idea... I believe static intializers are executed in textual order. So you could have a static code block after all static UnicodeBlock instances have been defined that asserts the size == 510 (or is <= 1024 * 0.75). In that case i would argue a static final representing the expected size is justified.
 
Then your test can derive the initial capacity from mapSize.

Paul.

> No named constant.
> A comment in the code about initial capacity.
> In the test, we use the same constant to check if it were sufficient to hold the final number of entries.
> 
> If someone evil shrinks the initial capacity in the code, the test will not be able to detect it, though it seems unlikely.
> 
> // Please ignore the change to test/TEST.groups in the webrev; it is a leftover from a fix for JDK-8080330
> 
> Sincerely yours,
> Ivan
> 




More information about the core-libs-dev mailing list