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 Project: jdk1.8-source-analysis   Author: raysonfang   File: ObjectOutputStream.java    License: 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 #2
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: ObjectOutputStream.java    License: 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: ObjectOutputStream.java    License: 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 Project: dragonwell8_jdk   Author: alibaba   File: ObjectOutputStream.java    License: 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 Project: dragonwell8_jdk   Author: alibaba   File: ObjectOutputStream.java    License: 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 Project: dragonwell8_jdk   Author: alibaba   File: ObjectOutputStream.java    License: 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 Project: TencentKona-8   Author: Tencent   File: ObjectOutputStream.java    License: 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 Project: TencentKona-8   Author: Tencent   File: ObjectOutputStream.java    License: 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 Project: TencentKona-8   Author: Tencent   File: ObjectOutputStream.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: ObjectOutputStream.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: ObjectOutputStream.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: ObjectOutputStream.java    License: 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 Project: JDKSourceCode1.8   Author: wupeixuan   File: ObjectOutputStream.java    License: 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 #14
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: ObjectOutputStream.java    License: MIT License 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 Project: JDKSourceCode1.8   Author: wupeixuan   File: ObjectOutputStream.java    License: MIT License 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 Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ObjectOutputStream.java    License: 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 Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ObjectOutputStream.java    License: 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 Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ObjectOutputStream.java    License: 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 Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ObjectOutputStream.java    License: 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 #20
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ObjectOutputStream.java    License: 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 #21
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ObjectOutputStream.java    License: 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 #22
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: ObjectOutputStream.java    License: 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 Project: jdk8u-jdk   Author: lambdalab-mirror   File: ObjectOutputStream.java    License: 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 Project: jdk8u-jdk   Author: lambdalab-mirror   File: ObjectOutputStream.java    License: 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 Project: Java8CN   Author: Java8-CNAPI-Team   File: ObjectOutputStream.java    License: 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 #26
Source Project: Java8CN   Author: Java8-CNAPI-Team   File: ObjectOutputStream.java    License: 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 Project: Java8CN   Author: Java8-CNAPI-Team   File: ObjectOutputStream.java    License: 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 Project: hottub   Author: dsrg-uoft   File: ObjectOutputStream.java    License: 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 Project: hottub   Author: dsrg-uoft   File: ObjectOutputStream.java    License: 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 Project: hottub   Author: dsrg-uoft   File: ObjectOutputStream.java    License: 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;
}