Reverting checks after toArray() calls

This is needed due to revert in I7463c5c2638af53caa2e0db8723167884ab34e4a

Test: m
Bug: 202956589
Bug: 204397945
Bug: 205812471
Change-Id: I038247bd7e5077981335f441ab38875335a1149c
diff --git a/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java b/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java
index f1a0bed..fb464e9 100644
--- a/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java
+++ b/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java
@@ -141,7 +141,10 @@
             es = ((CopyOnWriteArrayList<?>)c).getArray();
         else {
             es = c.toArray();
-            if (c.getClass() != java.util.ArrayList.class)
+            // Android-changed: Defend against c.toArray (incorrectly) not returning Object[]
+            //                  (see b/204397945)
+            // if (c.getClass() != java.util.ArrayList.class)
+            if (es.getClass() != Object[].class)
                 es = Arrays.copyOf(es, es.length, Object[].class);
         }
         setArray(es);
diff --git a/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java b/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java
index ee1c1b1..c068dee 100644
--- a/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java
+++ b/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java
@@ -263,7 +263,10 @@
         }
         Object[] es = c.toArray();
         int n = es.length;
-        if (c.getClass() != java.util.ArrayList.class)
+        // Android-changed: Defend against c.toArray (incorrectly) not returning Object[]
+        //                  (see b/204397945)
+        // if (c.getClass() != java.util.ArrayList.class)
+        if (es.getClass() != Object[].class)
             es = Arrays.copyOf(es, n, Object[].class);
         if (screen && (n == 1 || this.comparator != null)) {
             for (Object e : es)