mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8189989
: Improve container portability
Reviewed-by: prr, azvegint, rhalade, skoivu
This commit is contained in:
parent
f988f60dc8
commit
2bb8cb2d4a
1 changed files with 9 additions and 1 deletions
|
@ -35,6 +35,7 @@ import java.awt.peer.LightweightPeer;
|
|||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
|
@ -3720,8 +3721,15 @@ public class Container extends Component {
|
|||
throws ClassNotFoundException, IOException
|
||||
{
|
||||
ObjectInputStream.GetField f = s.readFields();
|
||||
Component [] tmpComponent = (Component[])f.get("component", EMPTY_ARRAY);
|
||||
// array of components may not be present in the stream or may be null
|
||||
Component [] tmpComponent = (Component[])f.get("component", null);
|
||||
if (tmpComponent == null) {
|
||||
tmpComponent = EMPTY_ARRAY;
|
||||
}
|
||||
int ncomponents = (Integer) f.get("ncomponents", 0);
|
||||
if (ncomponents < 0 || ncomponents > tmpComponent.length) {
|
||||
throw new InvalidObjectException("Incorrect number of components");
|
||||
}
|
||||
component = new java.util.ArrayList<Component>(ncomponents);
|
||||
for (int i = 0; i < ncomponents; ++i) {
|
||||
component.add(tmpComponent[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue