< prev index next >

test/jdk/java/lang/Character/UnicodeBlock/OptimalMapSize.java

Print this page
rev 54996 : 8221431: Support for Unicode 12.1
Reviewed-by:

*** 1,7 **** /* ! * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 21,31 **** * questions. */ /** * @test ! * @bug 8080535 8191410 8215194 * @summary Expected size of Character.UnicodeBlock.map is not optimal * @library /test/lib * @modules java.base/java.lang:open * java.base/java.util:open * @build jdk.test.lib.util.OptimalCapacity --- 21,31 ---- * questions. */ /** * @test ! * @bug 8080535 8191410 8215194 8221431 * @summary Expected size of Character.UnicodeBlock.map is not optimal * @library /test/lib * @modules java.base/java.lang:open * java.base/java.util:open * @build jdk.test.lib.util.OptimalCapacity
*** 44,69 **** // // After implementing support of Unicode 9 and 10 in Java, there will // be 638 entries in Character.UnicodeBlock.map. // // As of Unicode 11, 667 entries are expected. // // Initialization of the map and this test will have to be adjusted // accordingly then. // // Note that HashMap's implementation aligns the initial capacity to // a power of two size, so it will end up 1024 (and thus succeed) in ! // cases, such as 638 and 667. public class OptimalMapSize { public static void main(String[] args) throws Throwable { // The initial size of Character.UnicodeBlock.map. // See src/java.base/share/classes/java/lang/Character.java Field f = Character.UnicodeBlock.class.getDeclaredField("NUM_ENTITIES"); f.setAccessible(true); int num_entities = f.getInt(null); ! assert num_entities == 667; int initialCapacity = (int)(num_entities / 0.75f + 1.0f); OptimalCapacity.ofHashMap(Character.UnicodeBlock.class, "map", initialCapacity); } --- 44,70 ---- // // After implementing support of Unicode 9 and 10 in Java, there will // be 638 entries in Character.UnicodeBlock.map. // // As of Unicode 11, 667 entries are expected. + // As of Unicode 12.1, 676 entries are expected. // // Initialization of the map and this test will have to be adjusted // accordingly then. // // Note that HashMap's implementation aligns the initial capacity to // a power of two size, so it will end up 1024 (and thus succeed) in ! // cases, such as 638, 667, and 676. public class OptimalMapSize { public static void main(String[] args) throws Throwable { // The initial size of Character.UnicodeBlock.map. // See src/java.base/share/classes/java/lang/Character.java Field f = Character.UnicodeBlock.class.getDeclaredField("NUM_ENTITIES"); f.setAccessible(true); int num_entities = f.getInt(null); ! assert num_entities == 676; int initialCapacity = (int)(num_entities / 0.75f + 1.0f); OptimalCapacity.ofHashMap(Character.UnicodeBlock.class, "map", initialCapacity); }
< prev index next >