changeset 49078:e9676e9ca3d6

8197893: Mistaken type check in CheckedEntrySet.toArray Reviewed-by: psandoz
author martin
date Wed, 14 Feb 2018 16:37:20 -0800
parents fdd4a131d766
children 276b0604eab3
files src/java.base/share/classes/java/util/Collections.java
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/Collections.java	Wed Feb 14 14:13:42 2018 -0800
+++ b/src/java.base/share/classes/java/util/Collections.java	Wed Feb 14 16:37:20 2018 -0800
@@ -3771,9 +3771,9 @@
                  * Ensure that we don't get an ArrayStoreException even if
                  * s.toArray returns an array of something other than Object
                  */
-                Object[] dest = (CheckedEntry.class.isInstance(
-                    source.getClass().getComponentType()) ? source :
-                                 new Object[source.length]);
+                Object[] dest = (source.getClass() == Object[].class)
+                    ? source
+                    : new Object[source.length];
 
                 for (int i = 0; i < source.length; i++)
                     dest[i] = checkedEntry((Map.Entry<K,V>)source[i],