219 |
|
|
220 |
case TC_CLASSDESC: |
case TC_CLASSDESC: |
221 |
{ |
{ |
222 |
dumpElement ("CLASSDESC NAME="); |
ObjectStreamClass osc = readClassDescriptor (); |
|
String name = this.realInputStream.readUTF (); |
|
|
dumpElement (name + "; UID="); |
|
|
long uid = this.realInputStream.readLong (); |
|
|
dumpElement (Long.toHexString(uid) + "; FLAGS="); |
|
|
byte flags = this.realInputStream.readByte (); |
|
|
dumpElement (Integer.toHexString(flags) + "; FIELD COUNT="); |
|
|
short field_count = this.realInputStream.readShort (); |
|
|
dumpElementln (Short.toString(field_count)); |
|
|
ObjectStreamField[] fields = new ObjectStreamField[field_count]; |
|
|
ObjectStreamClass osc = new ObjectStreamClass (name, uid, |
|
|
flags, fields); |
|
|
assignNewHandle (osc); |
|
|
|
|
|
for (int i=0; i < field_count; i++) |
|
|
{ |
|
|
dumpElement (" TYPE CODE="); |
|
|
char type_code = (char)this.realInputStream.readByte (); |
|
|
dumpElement (type_code + "; FIELD NAME="); |
|
|
String field_name = this.realInputStream.readUTF (); |
|
|
dumpElementln (field_name); |
|
|
String class_name; |
|
|
|
|
|
if (type_code == 'L' || type_code == '[') |
|
|
class_name = (String)readObject (); |
|
|
else |
|
|
class_name = String.valueOf (type_code); |
|
|
|
|
|
// There're many cases you can't get java.lang.Class from |
|
|
// typename if your context class loader can't load it, |
|
|
// then use typename to construct the field |
|
|
fields[i] = |
|
|
new ObjectStreamField (field_name, class_name); |
|
|
} |
|
|
|
|
|
boolean oldmode = setBlockDataMode (true); |
|
|
osc.setClass (resolveClass (osc)); |
|
|
setBlockDataMode (oldmode); |
|
223 |
|
|
224 |
if (!is_consumed) |
if (!is_consumed) |
225 |
{ |
{ |
414 |
return ret_val; |
return ret_val; |
415 |
} |
} |
416 |
|
|
417 |
|
protected ObjectStreamClass readClassDescriptor () |
418 |
|
throws ClassNotFoundException, IOException |
419 |
|
{ |
420 |
|
dumpElement ("CLASSDESC NAME="); |
421 |
|
String name = this.realInputStream.readUTF (); |
422 |
|
dumpElement (name + "; UID="); |
423 |
|
long uid = this.realInputStream.readLong (); |
424 |
|
dumpElement (Long.toHexString(uid) + "; FLAGS="); |
425 |
|
byte flags = this.realInputStream.readByte (); |
426 |
|
dumpElement (Integer.toHexString(flags) + "; FIELD COUNT="); |
427 |
|
short field_count = this.realInputStream.readShort (); |
428 |
|
dumpElementln (Short.toString(field_count)); |
429 |
|
ObjectStreamField[] fields = new ObjectStreamField[field_count]; |
430 |
|
ObjectStreamClass osc = new ObjectStreamClass (name, uid, |
431 |
|
flags, fields); |
432 |
|
assignNewHandle (osc); |
433 |
|
|
434 |
|
for (int i=0; i < field_count; i++) |
435 |
|
{ |
436 |
|
dumpElement (" TYPE CODE="); |
437 |
|
char type_code = (char)this.realInputStream.readByte (); |
438 |
|
dumpElement (type_code + "; FIELD NAME="); |
439 |
|
String field_name = this.realInputStream.readUTF (); |
440 |
|
dumpElementln (field_name); |
441 |
|
String class_name; |
442 |
|
|
443 |
|
if (type_code == 'L' || type_code == '[') |
444 |
|
class_name = (String)readObject (); |
445 |
|
else |
446 |
|
class_name = String.valueOf (type_code); |
447 |
|
|
448 |
|
// There're many cases you can't get java.lang.Class from |
449 |
|
// typename if your context class loader can't load it, |
450 |
|
// then use typename to construct the field |
451 |
|
fields[i] = |
452 |
|
new ObjectStreamField (field_name, class_name); |
453 |
|
} |
454 |
|
|
455 |
|
boolean oldmode = setBlockDataMode (true); |
456 |
|
osc.setClass (resolveClass (osc)); |
457 |
|
setBlockDataMode (oldmode); |
458 |
|
|
459 |
|
return osc; |
460 |
|
} |
461 |
|
|
462 |
/** |
/** |
463 |
* Reads the current objects non-transient, non-static fields from |
* Reads the current objects non-transient, non-static fields from |
464 |
* the current class from the underlying output stream. |
* the current class from the underlying output stream. |