ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/HashMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/HashMap.java (file contents):
Revision 1.1 by jsr166, Wed Aug 23 05:33:00 2017 UTC vs.
Revision 1.3 by jsr166, Sun Oct 22 17:44:03 2017 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2 > * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4   *
5   * This code is free software; you can redistribute it and/or modify it
# Line 34 | Line 34 | import java.util.function.BiConsumer;
34   import java.util.function.BiFunction;
35   import java.util.function.Consumer;
36   import java.util.function.Function;
37 + import jdk.internal.misc.SharedSecrets;
38  
39   /**
40   * Hash table based implementation of the {@code Map} interface.  This
# Line 1394 | Line 1395 | public class HashMap<K,V> extends Abstra
1395      }
1396  
1397      /**
1398 <     * Save the state of the {@code HashMap} instance to a stream (i.e.,
1398 <     * serialize it).
1398 >     * Saves this map to a stream (that is, serializes it).
1399       *
1400 +     * @param s the stream
1401 +     * @throws IOException if an I/O error occurs
1402       * @serialData The <i>capacity</i> of the HashMap (the length of the
1403       *             bucket array) is emitted (int), followed by the
1404       *             <i>size</i> (an int, the number of key-value
# Line 1415 | Line 1417 | public class HashMap<K,V> extends Abstra
1417      }
1418  
1419      /**
1420 <     * Reconstitute the {@code HashMap} instance from a stream (i.e.,
1421 <     * deserialize it).
1420 >     * Reconstitutes this map from a stream (that is, deserializes it).
1421 >     * @param s the stream
1422 >     * @throws ClassNotFoundException if the class of a serialized object
1423 >     *         could not be found
1424 >     * @throws IOException if an I/O error occurs
1425       */
1426      private void readObject(java.io.ObjectInputStream s)
1427          throws IOException, ClassNotFoundException {
# Line 1444 | Line 1449 | public class HashMap<K,V> extends Abstra
1449              float ft = (float)cap * lf;
1450              threshold = ((cap < MAXIMUM_CAPACITY && ft < MAXIMUM_CAPACITY) ?
1451                           (int)ft : Integer.MAX_VALUE);
1452 +
1453 +            // Check Map.Entry[].class since it's the nearest public type to
1454 +            // what we're actually creating.
1455 +            SharedSecrets.getJavaObjectInputStreamAccess().checkArray(s, Map.Entry[].class, cap);
1456              @SuppressWarnings({"rawtypes","unchecked"})
1457              Node<K,V>[] tab = (Node<K,V>[])new Node[cap];
1458              table = tab;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines