MCPcopy Create free account
hub / github.com/ReadyTalk/avian / writeObject

Method writeObject

classpath/java/io/ObjectOutputStream.java:283–309  ·  view source on GitHub ↗
(Object o)

Source from the content-addressed store, hash-verified

281 }
282
283 public void writeObject(Object o) throws IOException {
284 if (o == null) {
285 rawByte(TC_NULL);
286 return;
287 }
288 if (o instanceof String) {
289 byte[] bytes = ((String)o).getBytes("UTF-8");
290 rawByte(TC_STRING);
291 rawShort(bytes.length);
292 write(bytes);
293 return;
294 }
295 rawByte(TC_OBJECT);
296 Method writeObject = getReadOrWriteMethod(o, "writeObject");
297 if (writeObject == null) {
298 classDesc(o.getClass(), 0);
299 defaultWriteObject(o);
300 } else try {
301 classDesc(o.getClass(), SC_WRITE_METHOD);
302 current = o;
303 writeObject.invoke(o, this);
304 current = null;
305 rawByte(TC_ENDBLOCKDATA);
306 } catch (Exception e) {
307 throw new IOException(e);
308 }
309 }
310
311 static Method getReadOrWriteMethod(Object o, String methodName) {
312 try {

Callers 2

mainMethod · 0.95
fieldMethod · 0.95

Calls 9

rawByteMethod · 0.95
rawShortMethod · 0.95
writeMethod · 0.95
getReadOrWriteMethodMethod · 0.95
classDescMethod · 0.95
defaultWriteObjectMethod · 0.95
invokeMethod · 0.95
getBytesMethod · 0.80
getClassMethod · 0.45

Tested by 1

mainMethod · 0.76