From 11fc13ca23b7c5944ce2659dbef826369433ae77 Mon Sep 17 00:00:00 2001 From: igerasim Date: Mon, 5 Feb 2018 04:31:19 -0800 Subject: [PATCH] 8189981: Improve queuing portability Reviewed-by: skoivu, rhalade, chegar, igerasim --- .../classes/java/util/concurrent/PriorityBlockingQueue.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java index db888250c..d124a3ea9 100644 --- a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -48,6 +48,7 @@ import java.util.Queue; import java.util.SortedSet; import java.util.Spliterator; import java.util.function.Consumer; +import sun.misc.SharedSecrets; /** * An unbounded {@linkplain BlockingQueue blocking queue} that uses @@ -940,7 +941,9 @@ public class PriorityBlockingQueue extends AbstractQueue throws java.io.IOException, ClassNotFoundException { try { s.defaultReadObject(); - this.queue = new Object[q.size()]; + int sz = q.size(); + SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, sz); + this.queue = new Object[sz]; comparator = q.comparator(); addAll(q); } finally { -- GitLab