< prev index next >

src/java.base/share/classes/java/util/ImmutableCollections.java

Print this page

        

@@ -416,14 +416,16 @@
                 return e1;
             }
             throw outOfBounds(index);
         }
 
+        @java.io.Serial
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
 
+        @java.io.Serial
         private Object writeReplace() {
             if (e1 == null) {
                 return new CollSer(CollSer.IMM_LIST, e0);
             } else {
                 return new CollSer(CollSer.IMM_LIST, e0, e1);

@@ -496,14 +498,16 @@
         @Override
         public E get(int index) {
             return elements[index];
         }
 
+        @java.io.Serial
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
 
+        @java.io.Serial
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_LIST, elements);
         }
 
         @Override

@@ -621,14 +625,16 @@
                     }
                 }
             };
         }
 
+        @java.io.Serial
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
 
+        @java.io.Serial
         private Object writeReplace() {
             if (e1 == null) {
                 return new CollSer(CollSer.IMM_SET, e0);
             } else {
                 return new CollSer(CollSer.IMM_SET, e0, e1);

@@ -804,14 +810,16 @@
                     idx = 0;
                 }
             }
         }
 
+        @java.io.Serial
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
 
+        @java.io.Serial
         private Object writeReplace() {
             Object[] array = new Object[size];
             int dest = 0;
             for (Object o : elements) {
                 if (o != null) {

@@ -904,14 +912,16 @@
         @Override
         public boolean isEmpty() {
             return false;
         }
 
+        @java.io.Serial
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
 
+        @java.io.Serial
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_MAP, k0, v0);
         }
 
         @Override

@@ -1108,14 +1118,16 @@
                     idx = 0;
                 }
             }
         }
 
+        @java.io.Serial
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
 
+        @java.io.Serial
         private Object writeReplace() {
             Object[] array = new Object[2 * size];
             int len = table.length;
             int dest = 0;
             for (int i = 0; i < len; i += 2) {

@@ -1136,10 +1148,11 @@
  *
  * @serial
  * @since 9
  */
 final class CollSer implements Serializable {
+    @java.io.Serial
     private static final long serialVersionUID = 6309168927139932177L;
 
     static final int IMM_LIST = 1;
     static final int IMM_SET = 2;
     static final int IMM_MAP = 3;

@@ -1196,10 +1209,11 @@
      * @throws IOException if an I/O error occurs
      * @throws ClassNotFoundException if a serialized class cannot be loaded
      * @throws InvalidObjectException if the count is negative
      * @since 9
      */
+    @java.io.Serial
     private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
         ois.defaultReadObject();
         int len = ois.readInt();
 
         if (len < 0) {

@@ -1225,10 +1239,11 @@
      *
      * @param oos the ObjectOutputStream to which data is written
      * @throws IOException if an I/O error occurs
      * @since 9
      */
+    @java.io.Serial
     private void writeObject(ObjectOutputStream oos) throws IOException {
         oos.defaultWriteObject();
         oos.writeInt(array.length);
         for (int i = 0; i < array.length; i++) {
             oos.writeObject(array[i]);

@@ -1251,10 +1266,11 @@
      * @throws InvalidObjectException if the tag value is illegal or if an exception
      *         is thrown during creation of the collection
      * @throws ObjectStreamException if another serialization error has occurred
      * @since 9
      */
+   @java.io.Serial
     private Object readResolve() throws ObjectStreamException {
         try {
             if (array == null) {
                 throw new InvalidObjectException("null array");
             }
< prev index next >