-
Bug
-
Resolution: Fixed
-
P5
-
None
-
b04
-
Not verified
The constructor WeakHashMap(Map<? extends K, ? extends V> m) delegates construction as
this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1,
DEFAULT_INITIAL_CAPACITY),
DEFAULT_LOAD_FACTOR);
If m.size() is large (>= 1610612672) then the first argument of Math.max() becomes negative due to integer overflow, and WeakHashMap with default capacity is created.
While it is mostly unnoticeable, it is unnecessary.
this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1,
DEFAULT_INITIAL_CAPACITY),
DEFAULT_LOAD_FACTOR);
If m.size() is large (>= 1610612672) then the first argument of Math.max() becomes negative due to integer overflow, and WeakHashMap with default capacity is created.
While it is mostly unnoticeable, it is unnecessary.
- links to