< prev index next >

src/java.base/share/classes/java/io/ObjectOutputStream.java

Print this page

1166             if (obj != orig) {
1167                 subs.assign(orig, obj);
1168                 if (obj == null) {
1169                     writeNull();
1170                     return;
1171                 } else if (!unshared && (h = handles.lookup(obj)) != -1) {
1172                     writeHandle(h);
1173                     return;
1174                 } else if (obj instanceof Class) {
1175                     writeClass((Class) obj, unshared);
1176                     return;
1177                 } else if (obj instanceof ObjectStreamClass) {
1178                     writeClassDesc((ObjectStreamClass) obj, unshared);
1179                     return;
1180                 }
1181             }
1182 
1183             // remaining cases
1184             if (obj instanceof String) {
1185                 writeString((String) obj, unshared);


1186             } else if (cl.isArray()) {
1187                 writeArray(obj, desc, unshared);
1188             } else if (obj instanceof Enum) {
1189                 writeEnum((Enum<?>) obj, desc, unshared);
1190             } else if (obj instanceof Serializable) {
1191                 writeOrdinaryObject(obj, desc, unshared);
1192             } else {
1193                 if (extendedDebugInfo) {
1194                     throw new NotSerializableException(
1195                         cl.getName() + "\n" + debugInfoStack.toString());
1196                 } else {
1197                     throw new NotSerializableException(cl.getName());
1198                 }
1199             }
1200         } finally {
1201             depth--;
1202             bout.setBlockDataMode(oldMode);
1203         }
1204     }
1205 

1166             if (obj != orig) {
1167                 subs.assign(orig, obj);
1168                 if (obj == null) {
1169                     writeNull();
1170                     return;
1171                 } else if (!unshared && (h = handles.lookup(obj)) != -1) {
1172                     writeHandle(h);
1173                     return;
1174                 } else if (obj instanceof Class) {
1175                     writeClass((Class) obj, unshared);
1176                     return;
1177                 } else if (obj instanceof ObjectStreamClass) {
1178                     writeClassDesc((ObjectStreamClass) obj, unshared);
1179                     return;
1180                 }
1181             }
1182 
1183             // remaining cases
1184             if (obj instanceof String) {
1185                 writeString((String) obj, unshared);
1186             } else if (cl.isPrimitiveClass()) {
1187                 throw new NotSerializableException(cl.getName());
1188             } else if (cl.isArray()) {
1189                 writeArray(obj, desc, unshared);
1190             } else if (obj instanceof Enum) {
1191                 writeEnum((Enum<?>) obj, desc, unshared);
1192             } else if (obj instanceof Serializable) {
1193                 writeOrdinaryObject(obj, desc, unshared);
1194             } else {
1195                 if (extendedDebugInfo) {
1196                     throw new NotSerializableException(
1197                         cl.getName() + "\n" + debugInfoStack.toString());
1198                 } else {
1199                     throw new NotSerializableException(cl.getName());
1200                 }
1201             }
1202         } finally {
1203             depth--;
1204             bout.setBlockDataMode(oldMode);
1205         }
1206     }
1207 
< prev index next >