< prev index next >

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

Print this page

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


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

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