Currently HashMap.keySet().toArray(), HashMap.values().toArray(), HashSet.toArray(), LinkedHashMap.keySet().toArray(), LinkedHashMap.values().toArray(), LinkedHashSet.toArray() delegate to AbstractCollection implementation which creates an iterator. This is suboptimal as the corresponding iterator (e.g. HashMap.KeyIterator) should track current state which is quite non-trivial for HashMap. Also modCount is constantly compared with expectedModCount which is also redundant. It seems that existing JIT compilers (C2, Graal) cannot totally eliminate the overhead. I believe that these methods are used quite often (especially HashSet.toArray()) to deserve a specialized implementation similar to LinkedList.toArray().