changeset 8855:995d7feafcff

8213432: Better copies of CopiesList Reviewed-by: rriggs, skoivu, ahgross, robm, rhalade, jeff
author andrew
date Mon, 15 Jul 2019 04:24:51 +0100
parents 8a05a0d8dcda
children 708f34dd480f
files src/share/classes/java/util/Collections.java
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Collections.java	Wed Jan 30 19:33:04 2019 -0800
+++ b/src/share/classes/java/util/Collections.java	Mon Jul 15 04:24:51 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,13 @@
 
 package java.util;
 import java.io.Serializable;
+import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.IOException;
 import java.lang.reflect.Array;
 
+import sun.misc.SharedSecrets;
+
 /**
  * This class consists exclusively of static methods that operate on or return
  * collections.  It contains polymorphic algorithms that operate on
@@ -3538,6 +3541,11 @@
                                                    ") > toIndex(" + toIndex + ")");
             return new CopiesList<>(toIndex - fromIndex, element);
         }
+
+        private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+            ois.defaultReadObject();
+            SharedSecrets.getJavaOISAccess().checkArray(ois, Object[].class, n);
+        }
     }
 
     /**