RFR 8081027: Create a common test to check adequacy of initial size of static HashMap/ArrayList fields (original) (raw)
Martin Buchholz martinrb at google.com
Wed May 27 14:30:36 UTC 2015
- Previous message: RFR 8081027: Create a common test to check adequacy of initial size of static HashMap/ArrayList fields
- Next message: RFR 8081027: Create a common test to check adequacy of initial size of static HashMap/ArrayList fields
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks.
Your methods like ofArrayList declare that they throw ReflectiveOperationException, but also have a try/catch to prevent that from ever happening.
The assertions e.g. OptimalCapacity.ofArrayList(XClass.class, "theList", N) could look more like assertions, e.g. OptimalCapacity.assertOptimallySized(Class<?> clazz, String fieldName, int initialCapacity)
getStorage returns the actual internal array, but you only ever need the length. Maybe I would have a single method
static int internalArraySize(Object x) { ... }
"enteties" is misspelled.
For ArrayLists, I would have been happy enough just testing that we have 100% utilization, i.e. size of array is the same as size of the List, without checking the initial capacity.
On Mon, May 25, 2015 at 4:07 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
Hello!
This is in some way continuation of JDK-8080535 (Expected size of Character.UnicodeBlock.map is not optimal). A new utility class OptimalCapacity was added to jdk.testlibrary package. The test NonOptimalMapSize.java that had been added with JDK-8080535, was rewritten with use of this new class. A couple more tests were added, which utilize methods of OptimalCapacity for checking sizes of ArrayList and IdentityHashMap static variables. Optimization of initial sizes of two more variables saves us one reallocation during java start-time and a few more bytes of memory. Would you please help review this fix? BUGURL: https://bugs.openjdk.java.net/browse/JDK-8081027 WEBREV: http://cr.openjdk.java.net/~igerasim/8081027/00/webrev/ Sincerely yours, Ivan
- Previous message: RFR 8081027: Create a common test to check adequacy of initial size of static HashMap/ArrayList fields
- Next message: RFR 8081027: Create a common test to check adequacy of initial size of static HashMap/ArrayList fields
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]