25 |
|
|
26 |
|
package java.util; |
27 |
|
|
28 |
+ |
import java.io.IOException; |
29 |
+ |
import java.io.ObjectInputStream; |
30 |
+ |
import java.io.StreamCorruptedException; |
31 |
|
import java.util.function.Consumer; |
32 |
|
import java.util.function.Predicate; |
33 |
|
import java.util.function.UnaryOperator; |
1180 |
|
} |
1181 |
|
|
1182 |
|
/** |
1183 |
+ |
* Loads a {@code Vector} instance from a stream |
1184 |
+ |
* (that is, deserializes it). |
1185 |
+ |
* This method performs checks to ensure the consistency |
1186 |
+ |
* of the fields. |
1187 |
+ |
* |
1188 |
+ |
* @param in the stream |
1189 |
+ |
* @throws java.io.IOException if an I/O error occurs |
1190 |
+ |
* @throws ClassNotFoundException if the stream contains data |
1191 |
+ |
* of a non-existing class |
1192 |
+ |
*/ |
1193 |
+ |
private void readObject(ObjectInputStream in) |
1194 |
+ |
throws IOException, ClassNotFoundException { |
1195 |
+ |
ObjectInputStream.GetField gfields = in.readFields(); |
1196 |
+ |
int count = gfields.get("elementCount", 0); |
1197 |
+ |
Object[] data = (Object[])gfields.get("elementData", null); |
1198 |
+ |
if (count < 0 || data == null || count > data.length) { |
1199 |
+ |
throw new StreamCorruptedException("Inconsistent vector internals"); |
1200 |
+ |
} |
1201 |
+ |
elementCount = count; |
1202 |
+ |
elementData = data.clone(); |
1203 |
+ |
} |
1204 |
+ |
|
1205 |
+ |
/** |
1206 |
|
* Saves the state of the {@code Vector} instance to a stream |
1207 |
|
* (that is, serializes it). |
1208 |
|
* This method performs synchronization to ensure the consistency |