-
Bug
-
Resolution: Fixed
-
P4
-
20
-
None
HashMap::newHashMap and related methods, added by JDK-8186958, specify that a negative argument will throw IllegalArgumentException. This occurs today, because a negative argument will be passed through calculateHashMapCapacity and then to a constructor, which will throw IAE. However, it seems unwise to rely on calculateHashMapCapacity always to provide a negative result if given a negative argument. (Indeed, some of the alternative implementations of this method returned a positive result given a negative argument.)
Thus it seems prudent to add a test that ensures that the new HashMap-related static factory methods always throw IAE when given a negative argument, and further, checks should be added in the method implementations to break the reliance on this specific behavior of calculateHashMapCapacity.
Thus it seems prudent to add a test that ensures that the new HashMap-related static factory methods always throw IAE when given a negative argument, and further, checks should be added in the method implementations to break the reliance on this specific behavior of calculateHashMapCapacity.
- relates to
-
JDK-8186958 Need method to create pre-sized HashMap
- Resolved