java.io.SerialCallbackContext Java Examples

The following examples show how to use java.io.SerialCallbackContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectOutputStream.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #2
Source File: ObjectOutputStream.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #3
Source File: ObjectOutputStream.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #4
Source File: ObjectOutputStream.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #5
Source File: ObjectOutputStream.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #6
Source File: ObjectOutputStream.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #7
Source File: ObjectOutputStream.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #8
Source File: ObjectOutputStream.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #9
Source File: ObjectOutputStream.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #10
Source File: ObjectOutputStream.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #11
Source File: ObjectOutputStream.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #12
Source File: ObjectOutputStream.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #13
Source File: ObjectOutputStream.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #14
Source File: ObjectOutputStream.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #15
Source File: ObjectOutputStream.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #16
Source File: ObjectOutputStream.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #17
Source File: ObjectOutputStream.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #18
Source File: ObjectOutputStream.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #19
Source File: ObjectOutputStream.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #20
Source File: ObjectOutputStream.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #21
Source File: ObjectOutputStream.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #22
Source File: ObjectOutputStream.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #23
Source File: ObjectOutputStream.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #24
Source File: ObjectOutputStream.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #25
Source File: ObjectOutputStream.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #26
Source File: ObjectOutputStream.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #27
Source File: ObjectOutputStream.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}
 
Example #28
Source File: ObjectOutputStream.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write the non-static and non-transient fields of the current class to
 * this stream.  This may only be called from the writeObject method of the
 * class being serialized. It will throw the NotActiveException if it is
 * called otherwise.
 *
 * @throws  IOException if I/O errors occur while writing to the underlying
 *          <code>OutputStream</code>
 */
public void defaultWriteObject() throws IOException {
    SerialCallbackContext ctx = curContext;
    if (ctx == null) {
        throw new NotActiveException("not in call to writeObject");
    }
    Object curObj = ctx.getObj();
    ObjectStreamClass curDesc = ctx.getDesc();
    bout.setBlockDataMode(false);
    defaultWriteFields(curObj, curDesc);
    bout.setBlockDataMode(true);
}
 
Example #29
Source File: ObjectOutputStream.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the object used to buffer persistent fields to be written to
 * the stream.  The fields will be written to the stream when writeFields
 * method is called.
 *
 * @return  an instance of the class Putfield that holds the serializable
 *          fields
 * @throws  IOException if I/O errors occur
 * @since 1.2
 */
public ObjectOutputStream.PutField putFields() throws IOException {
    if (curPut == null) {
        SerialCallbackContext ctx = curContext;
        if (ctx == null) {
            throw new NotActiveException("not in call to writeObject");
        }
        Object curObj = ctx.getObj();
        ObjectStreamClass curDesc = ctx.getDesc();
        curPut = new PutFieldImpl(curDesc);
    }
    return curPut;
}
 
Example #30
Source File: ObjectOutputStream.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes externalizable data of given object by invoking its
 * writeExternal() method.
 */
private void writeExternalData(Externalizable obj) throws IOException {
    PutFieldImpl oldPut = curPut;
    curPut = null;

    if (extendedDebugInfo) {
        debugInfoStack.push("writeExternal data");
    }
    SerialCallbackContext oldContext = curContext;
    try {
        curContext = null;
        if (protocol == PROTOCOL_VERSION_1) {
            obj.writeExternal(this);
        } else {
            bout.setBlockDataMode(true);
            obj.writeExternal(this);
            bout.setBlockDataMode(false);
            bout.writeByte(TC_ENDBLOCKDATA);
        }
    } finally {
        curContext = oldContext;
        if (extendedDebugInfo) {
            debugInfoStack.pop();
        }
    }

    curPut = oldPut;
}