8189981: Improve queuing portability
authorsmarks
Fri, 02 Feb 2018 10:56:12 -0800
changeset 49792 cfdce76e0449
parent 49791 a0ac3c9b76dc
child 49793 a73fcbe66a57
8189981: Improve queuing portability Reviewed-by: skoivu, rhalade, chegar, igerasim
src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
--- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Fri Jan 26 12:01:08 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Fri Feb 02 10:56:12 2018 -0800
@@ -51,6 +51,7 @@
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.Consumer;
+import jdk.internal.misc.SharedSecrets;
 
 /**
  * An unbounded {@linkplain BlockingQueue blocking queue} that uses
@@ -921,7 +922,9 @@
         throws java.io.IOException, ClassNotFoundException {
         try {
             s.defaultReadObject();
-            this.queue = new Object[q.size()];
+            int sz = q.size();
+            SharedSecrets.getJavaObjectInputStreamAccess().checkArray(s, Object[].class, sz);
+            this.queue = new Object[sz];
             comparator = q.comparator();
             addAll(q);
         } finally {