144 |
protocolVersion = defaultProtocolVersion; |
protocolVersion = defaultProtocolVersion; |
145 |
useSubclassMethod = false; |
useSubclassMethod = false; |
146 |
writeStreamHeader(); |
writeStreamHeader(); |
147 |
|
|
148 |
|
if (Configuration.DEBUG) |
149 |
|
{ |
150 |
|
String val = System.getProperty("gcj.dumpobjects"); |
151 |
|
if (val != null && !val.equals("")) |
152 |
|
dump = true; |
153 |
|
} |
154 |
} |
} |
155 |
|
|
156 |
/** |
/** |
179 |
{ |
{ |
180 |
if (useSubclassMethod) |
if (useSubclassMethod) |
181 |
{ |
{ |
182 |
|
if (dump) |
183 |
|
dumpElementln ("WRITE OVERRIDE: " + obj); |
184 |
|
|
185 |
writeObjectOverride(obj); |
writeObjectOverride(obj); |
186 |
return; |
return; |
187 |
} |
} |
188 |
|
|
189 |
|
if (dump) |
190 |
|
dumpElementln ("WRITE: " + obj); |
191 |
|
|
192 |
|
depth += 2; |
193 |
|
|
194 |
boolean was_serializing = isSerializing; |
boolean was_serializing = isSerializing; |
195 |
boolean old_mode = setBlockDataMode(false); |
boolean old_mode = setBlockDataMode(false); |
196 |
try |
try |
333 |
|
|
334 |
if (obj instanceof Serializable) |
if (obj instanceof Serializable) |
335 |
{ |
{ |
336 |
|
Object prevObject = this.currentObject; |
337 |
|
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass; |
338 |
currentObject = obj; |
currentObject = obj; |
339 |
ObjectStreamClass[] hierarchy = |
ObjectStreamClass[] hierarchy = |
340 |
ObjectStreamClass.getObjectStreamClasses(clazz); |
ObjectStreamClass.getObjectStreamClasses(clazz); |
346 |
fieldsAlreadyWritten = false; |
fieldsAlreadyWritten = false; |
347 |
if (currentObjectStreamClass.hasWriteMethod()) |
if (currentObjectStreamClass.hasWriteMethod()) |
348 |
{ |
{ |
349 |
|
if (dump) |
350 |
|
dumpElementln ("WRITE METHOD CALLED FOR: " + obj); |
351 |
setBlockDataMode(true); |
setBlockDataMode(true); |
352 |
callWriteMethod(obj, currentObjectStreamClass); |
callWriteMethod(obj, currentObjectStreamClass); |
353 |
setBlockDataMode(false); |
setBlockDataMode(false); |
354 |
realOutput.writeByte(TC_ENDBLOCKDATA); |
realOutput.writeByte(TC_ENDBLOCKDATA); |
355 |
|
if (dump) |
356 |
|
dumpElementln ("WRITE ENDBLOCKDATA FOR: " + obj); |
357 |
} |
} |
358 |
else |
else |
359 |
|
{ |
360 |
|
if (dump) |
361 |
|
dumpElementln ("WRITE FIELDS CALLED FOR: " + obj); |
362 |
writeFields(obj, currentObjectStreamClass); |
writeFields(obj, currentObjectStreamClass); |
363 |
} |
} |
364 |
|
} |
365 |
|
|
366 |
currentObject = null; |
this.currentObject = prevObject; |
367 |
currentObjectStreamClass = null; |
this.currentObjectStreamClass = prevObjectStreamClass; |
368 |
currentPutField = null; |
currentPutField = null; |
369 |
break; |
break; |
370 |
} |
} |
385 |
setBlockDataMode(false); |
setBlockDataMode(false); |
386 |
try |
try |
387 |
{ |
{ |
388 |
|
if (Configuration.DEBUG) |
389 |
|
{ |
390 |
|
e.printStackTrace(System.out); |
391 |
|
} |
392 |
writeObject(e); |
writeObject(e); |
393 |
} |
} |
394 |
catch (IOException ioe) |
catch (IOException ioe) |
395 |
{ |
{ |
396 |
throw new StreamCorruptedException |
StreamCorruptedException ex = |
397 |
("Exception " + ioe + " thrown while exception was being written to stream."); |
new StreamCorruptedException |
398 |
|
(ioe + " thrown while exception was being written to stream."); |
399 |
|
if (Configuration.DEBUG) |
400 |
|
{ |
401 |
|
ex.printStackTrace(System.out); |
402 |
|
} |
403 |
|
throw ex; |
404 |
} |
} |
405 |
|
|
406 |
reset (true); |
reset (true); |
410 |
{ |
{ |
411 |
isSerializing = was_serializing; |
isSerializing = was_serializing; |
412 |
setBlockDataMode(old_mode); |
setBlockDataMode(old_mode); |
413 |
|
depth -= 2; |
414 |
|
|
415 |
|
if (dump) |
416 |
|
dumpElementln ("END: " + obj); |
417 |
} |
} |
418 |
} |
} |
419 |
|
|
1210 |
field_name = fields[i].getName(); |
field_name = fields[i].getName(); |
1211 |
type = fields[i].getType(); |
type = fields[i].getType(); |
1212 |
|
|
1213 |
|
if (dump) |
1214 |
|
dumpElementln ("WRITE FIELD: " + field_name + " type=" + type); |
1215 |
|
|
1216 |
if (type == Boolean.TYPE) |
if (type == Boolean.TYPE) |
1217 |
realOutput.writeBoolean(getBooleanField(obj, osc.forClass(), field_name)); |
realOutput.writeBoolean(getBooleanField(obj, osc.forClass(), field_name)); |
1218 |
else if (type == Byte.TYPE) |
else if (type == Byte.TYPE) |
1554 |
return m; |
return m; |
1555 |
} |
} |
1556 |
|
|
1557 |
|
private void dumpElementln (String msg) |
1558 |
|
{ |
1559 |
|
for (int i = 0; i < depth; i++) |
1560 |
|
System.out.print (" "); |
1561 |
|
System.out.print (Thread.currentThread() + ": "); |
1562 |
|
System.out.println(msg); |
1563 |
|
} |
1564 |
|
|
1565 |
// this value comes from 1.2 spec, but is used in 1.1 as well |
// this value comes from 1.2 spec, but is used in 1.1 as well |
1566 |
private final static int BUFFER_SIZE = 1024; |
private final static int BUFFER_SIZE = 1024; |
1567 |
|
|
1584 |
private int protocolVersion; |
private int protocolVersion; |
1585 |
private boolean useSubclassMethod; |
private boolean useSubclassMethod; |
1586 |
|
|
1587 |
|
// The nesting depth for debugging output |
1588 |
|
private int depth = 0; |
1589 |
|
|
1590 |
|
// Set if we're generating debugging dumps |
1591 |
|
private boolean dump = false; |
1592 |
|
|
1593 |
static |
static |
1594 |
{ |
{ |
1595 |
if (Configuration.INIT_LOAD_LIBRARY) |
if (Configuration.INIT_LOAD_LIBRARY) |