37 import java.security.PrivilegedExceptionAction; |
37 import java.security.PrivilegedExceptionAction; |
38 import java.util.Arrays; |
38 import java.util.Arrays; |
39 import java.util.HashMap; |
39 import java.util.HashMap; |
40 import java.util.concurrent.ConcurrentHashMap; |
40 import java.util.concurrent.ConcurrentHashMap; |
41 import java.util.concurrent.ConcurrentMap; |
41 import java.util.concurrent.ConcurrentMap; |
42 import java.util.concurrent.atomic.AtomicBoolean; |
|
43 import static java.io.ObjectStreamClass.processQueue; |
42 import static java.io.ObjectStreamClass.processQueue; |
44 import sun.reflect.misc.ReflectUtil; |
43 import sun.reflect.misc.ReflectUtil; |
45 |
44 |
46 /** |
45 /** |
47 * An ObjectInputStream deserializes primitive data and objects previously |
46 * An ObjectInputStream deserializes primitive data and objects previously |
532 { |
531 { |
533 SerialCallbackContext ctx = curContext; |
532 SerialCallbackContext ctx = curContext; |
534 if (ctx == null) { |
533 if (ctx == null) { |
535 throw new NotActiveException("not in call to readObject"); |
534 throw new NotActiveException("not in call to readObject"); |
536 } |
535 } |
537 Object curObj = ctx.getObj(); |
536 ctx.checkAndSetUsed(); |
538 ObjectStreamClass curDesc = ctx.getDesc(); |
537 ObjectStreamClass curDesc = ctx.getDesc(); |
539 bin.setBlockDataMode(false); |
538 bin.setBlockDataMode(false); |
540 GetFieldImpl getField = new GetFieldImpl(curDesc); |
539 GetFieldImpl getField = new GetFieldImpl(curDesc); |
541 getField.readFields(); |
540 getField.readFields(); |
542 bin.setBlockDataMode(true); |
541 bin.setBlockDataMode(true); |
1595 |
1594 |
1596 ObjectStreamClass desc = new ObjectStreamClass(); |
1595 ObjectStreamClass desc = new ObjectStreamClass(); |
1597 int descHandle = handles.assign(unshared ? unsharedMarker : desc); |
1596 int descHandle = handles.assign(unshared ? unsharedMarker : desc); |
1598 passHandle = NULL_HANDLE; |
1597 passHandle = NULL_HANDLE; |
1599 |
1598 |
1600 ObjectStreamClass readDesc = null; |
1599 ObjectStreamClass readDesc; |
1601 try { |
1600 try { |
1602 readDesc = readClassDescriptor(); |
1601 readDesc = readClassDescriptor(); |
1603 } catch (ClassNotFoundException ex) { |
1602 } catch (ClassNotFoundException ex) { |
1604 throw (IOException) new InvalidClassException( |
1603 throw (IOException) new InvalidClassException( |
1605 "failed to read class descriptor").initCause(ex); |
1604 "failed to read class descriptor").initCause(ex); |
1974 if (cl != null && obj != null && !cl.isInstance(obj)) { |
1973 if (cl != null && obj != null && !cl.isInstance(obj)) { |
1975 throw new ClassCastException(); |
1974 throw new ClassCastException(); |
1976 } |
1975 } |
1977 |
1976 |
1978 int primDataSize = desc.getPrimDataSize(); |
1977 int primDataSize = desc.getPrimDataSize(); |
1979 if (primVals == null || primVals.length < primDataSize) { |
1978 if (primDataSize > 0) { |
1980 primVals = new byte[primDataSize]; |
1979 if (primVals == null || primVals.length < primDataSize) { |
1981 } |
1980 primVals = new byte[primDataSize]; |
1982 bin.readFully(primVals, 0, primDataSize, false); |
1981 } |
1983 if (obj != null) { |
1982 bin.readFully(primVals, 0, primDataSize, false); |
1984 desc.setPrimFieldValues(obj, primVals); |
1983 if (obj != null) { |
1985 } |
1984 desc.setPrimFieldValues(obj, primVals); |
1986 |
1985 } |
1987 int objHandle = passHandle; |
1986 } |
1988 ObjectStreamField[] fields = desc.getFields(false); |
1987 |
1989 Object[] objVals = new Object[desc.getNumObjFields()]; |
1988 int numObjFields = desc.getNumObjFields(); |
1990 int numPrimFields = fields.length - objVals.length; |
1989 if (numObjFields > 0) { |
1991 for (int i = 0; i < objVals.length; i++) { |
1990 int objHandle = passHandle; |
1992 ObjectStreamField f = fields[numPrimFields + i]; |
1991 ObjectStreamField[] fields = desc.getFields(false); |
1993 objVals[i] = readObject0(f.isUnshared()); |
1992 Object[] objVals = new Object[numObjFields]; |
1994 if (f.getField() != null) { |
1993 int numPrimFields = fields.length - objVals.length; |
1995 handles.markDependency(objHandle, passHandle); |
1994 for (int i = 0; i < objVals.length; i++) { |
1996 } |
1995 ObjectStreamField f = fields[numPrimFields + i]; |
1997 } |
1996 objVals[i] = readObject0(f.isUnshared()); |
1998 if (obj != null) { |
1997 if (f.getField() != null) { |
1999 desc.setObjFieldValues(obj, objVals); |
1998 handles.markDependency(objHandle, passHandle); |
2000 } |
1999 } |
2001 passHandle = objHandle; |
2000 } |
|
2001 if (obj != null) { |
|
2002 desc.setObjFieldValues(obj, objVals); |
|
2003 } |
|
2004 passHandle = objHandle; |
|
2005 } |
2002 } |
2006 } |
2003 |
2007 |
2004 /** |
2008 /** |
2005 * Reads in and returns IOException that caused serialization to abort. |
2009 * Reads in and returns IOException that caused serialization to abort. |
2006 * All stream state is discarded prior to reading in fatal exception. Sets |
2010 * All stream state is discarded prior to reading in fatal exception. Sets |