52 |
import java.security.PrivilegedAction; |
import java.security.PrivilegedAction; |
53 |
import java.util.Arrays; |
import java.util.Arrays; |
54 |
import java.util.Hashtable; |
import java.util.Hashtable; |
55 |
|
import java.util.Iterator; |
56 |
|
import java.util.TreeSet; |
57 |
import java.util.Vector; |
import java.util.Vector; |
58 |
|
|
59 |
/** |
/** |
99 |
} |
} |
100 |
|
|
101 |
this.resolveEnabled = false; |
this.resolveEnabled = false; |
|
this.isDeserializing = false; |
|
102 |
this.blockDataPosition = 0; |
this.blockDataPosition = 0; |
103 |
this.blockDataBytes = 0; |
this.blockDataBytes = 0; |
104 |
this.blockData = new byte[BUFFER_SIZE]; |
this.blockData = new byte[BUFFER_SIZE]; |
106 |
this.realInputStream = new DataInputStream(in); |
this.realInputStream = new DataInputStream(in); |
107 |
this.nextOID = baseWireHandle; |
this.nextOID = baseWireHandle; |
108 |
this.objectLookupTable = new Hashtable<Integer,ObjectIdentityWrapper>(); |
this.objectLookupTable = new Hashtable<Integer,ObjectIdentityWrapper>(); |
|
this.validators = new Vector<ValidatorAndPriority>(); |
|
109 |
this.classLookupTable = new Hashtable<Class,ObjectStreamClass>(); |
this.classLookupTable = new Hashtable<Class,ObjectStreamClass>(); |
110 |
setBlockDataMode(true); |
setBlockDataMode(true); |
111 |
readStreamHeader(); |
readStreamHeader(); |
133 |
if (this.useSubclassMethod) |
if (this.useSubclassMethod) |
134 |
return readObjectOverride(); |
return readObjectOverride(); |
135 |
|
|
|
boolean was_deserializing; |
|
|
|
|
136 |
Object ret_val; |
Object ret_val; |
|
was_deserializing = this.isDeserializing; |
|
|
|
|
137 |
boolean old_mode = setBlockDataMode(false); |
boolean old_mode = setBlockDataMode(false); |
|
|
|
|
this.isDeserializing = true; |
|
|
|
|
138 |
byte marker = this.realInputStream.readByte(); |
byte marker = this.realInputStream.readByte(); |
139 |
|
|
140 |
depth += 2; |
if (DEBUG) |
141 |
|
depth += 2; |
142 |
|
|
143 |
if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " "); |
if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " "); |
144 |
|
|
145 |
try |
try |
146 |
{ |
{ |
147 |
ret_val = parseContent(marker); |
ret_val = parseContent(marker); |
148 |
} |
} |
149 |
finally |
finally |
150 |
{ |
{ |
151 |
setBlockDataMode(old_mode); |
setBlockDataMode(old_mode); |
152 |
|
if (DEBUG) |
153 |
this.isDeserializing = was_deserializing; |
depth -= 2; |
154 |
|
} |
155 |
depth -= 2; |
|
156 |
|
return ret_val; |
157 |
if (! was_deserializing) |
} |
|
{ |
|
|
if (validators.size() > 0) |
|
|
invokeValidators(); |
|
|
} |
|
|
} |
|
|
|
|
|
return ret_val; |
|
|
} |
|
158 |
|
|
159 |
/** |
/** |
160 |
* Handles a content block within the stream, which begins with a marker |
* Handles a content block within the stream, which begins with a marker |
228 |
for (int i = 0; i < n_intf; i++) |
for (int i = 0; i < n_intf; i++) |
229 |
{ |
{ |
230 |
intfs[i] = this.realInputStream.readUTF(); |
intfs[i] = this.realInputStream.readUTF(); |
|
System.out.println(intfs[i]); |
|
231 |
} |
} |
232 |
|
|
233 |
boolean oldmode = setBlockDataMode(true); |
boolean oldmode = setBlockDataMode(true); |
235 |
setBlockDataMode(oldmode); |
setBlockDataMode(oldmode); |
236 |
|
|
237 |
ObjectStreamClass osc = lookupClass(cl); |
ObjectStreamClass osc = lookupClass(cl); |
238 |
|
if (osc.firstNonSerializableParentConstructor == null) |
239 |
|
{ |
240 |
|
osc.realClassIsSerializable = true; |
241 |
|
osc.fields = osc.fieldMapping = new ObjectStreamField[0]; |
242 |
|
try |
243 |
|
{ |
244 |
|
osc.firstNonSerializableParentConstructor = |
245 |
|
Object.class.getConstructor(new Class[0]); |
246 |
|
} |
247 |
|
catch (NoSuchMethodException x) |
248 |
|
{ |
249 |
|
throw (InternalError) |
250 |
|
new InternalError("Object ctor missing").initCause(x); |
251 |
|
} |
252 |
|
} |
253 |
assignNewHandle(osc); |
assignNewHandle(osc); |
254 |
|
|
255 |
if (!is_consumed) |
if (!is_consumed) |
354 |
int handle = assignNewHandle(obj); |
int handle = assignNewHandle(obj); |
355 |
Object prevObject = this.currentObject; |
Object prevObject = this.currentObject; |
356 |
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass; |
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass; |
357 |
|
TreeSet<ValidatorAndPriority> prevObjectValidators = |
358 |
|
this.currentObjectValidators; |
359 |
|
|
360 |
this.currentObject = obj; |
this.currentObject = obj; |
361 |
|
this.currentObjectValidators = null; |
362 |
ObjectStreamClass[] hierarchy = |
ObjectStreamClass[] hierarchy = |
363 |
inputGetObjectStreamClasses(clazz); |
inputGetObjectStreamClasses(clazz); |
364 |
|
|
410 |
this.currentObject = prevObject; |
this.currentObject = prevObject; |
411 |
this.currentObjectStreamClass = prevObjectStreamClass; |
this.currentObjectStreamClass = prevObjectStreamClass; |
412 |
ret_val = processResolution(osc, obj, handle); |
ret_val = processResolution(osc, obj, handle); |
413 |
|
if (currentObjectValidators != null) |
414 |
|
invokeValidators(); |
415 |
|
this.currentObjectValidators = prevObjectValidators; |
416 |
|
|
417 |
break; |
break; |
418 |
} |
} |
419 |
|
|
745 |
throw new InvalidObjectException("attempt to add a null " |
throw new InvalidObjectException("attempt to add a null " |
746 |
+ "ObjectInputValidation object"); |
+ "ObjectInputValidation object"); |
747 |
|
|
748 |
this.validators.addElement(new ValidatorAndPriority (validator, |
if (currentObjectValidators == null) |
749 |
priority)); |
currentObjectValidators = new TreeSet<ValidatorAndPriority>(); |
750 |
|
|
751 |
|
currentObjectValidators.add(new ValidatorAndPriority(validator, priority)); |
752 |
} |
} |
753 |
|
|
754 |
|
|
1852 |
// on OBJ |
// on OBJ |
1853 |
private void invokeValidators() throws InvalidObjectException |
private void invokeValidators() throws InvalidObjectException |
1854 |
{ |
{ |
|
Object[] validators = new Object[this.validators.size()]; |
|
|
this.validators.copyInto (validators); |
|
|
Arrays.sort (validators); |
|
|
|
|
1855 |
try |
try |
1856 |
{ |
{ |
1857 |
for (int i=0; i < validators.length; i++) |
Iterator<ValidatorAndPriority> it = currentObjectValidators.iterator(); |
1858 |
((ObjectInputValidation)validators[i]).validateObject(); |
while(it.hasNext()) |
1859 |
|
{ |
1860 |
|
ValidatorAndPriority vap = it.next(); |
1861 |
|
ObjectInputValidation validator = vap.validator; |
1862 |
|
validator.validateObject(); |
1863 |
|
} |
1864 |
} |
} |
1865 |
finally |
finally |
1866 |
{ |
{ |
1867 |
this.validators.removeAllElements(); |
currentObjectValidators = null; |
1868 |
} |
} |
1869 |
} |
} |
1870 |
|
|
1913 |
private Hashtable<Integer,ObjectIdentityWrapper> objectLookupTable; |
private Hashtable<Integer,ObjectIdentityWrapper> objectLookupTable; |
1914 |
private Object currentObject; |
private Object currentObject; |
1915 |
private ObjectStreamClass currentObjectStreamClass; |
private ObjectStreamClass currentObjectStreamClass; |
1916 |
|
private TreeSet<ValidatorAndPriority> currentObjectValidators; |
1917 |
private boolean readDataFromBlock; |
private boolean readDataFromBlock; |
|
private boolean isDeserializing; |
|
1918 |
private boolean fieldsAlreadyRead; |
private boolean fieldsAlreadyRead; |
|
private Vector<ValidatorAndPriority> validators; |
|
1919 |
private Hashtable<Class,ObjectStreamClass> classLookupTable; |
private Hashtable<Class,ObjectStreamClass> classLookupTable; |
1920 |
private GetField prereadFields; |
private GetField prereadFields; |
1921 |
|
|