Java 类java.io.NotActiveException 实例源码

项目:OpenJSharp    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:OpenJSharp    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:openjdk-jdk10    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:openjdk-jdk10    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:openjdk9    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:openjdk9    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:lookaside_java-1.8.0-openjdk    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:jdk8u_corba    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:jdk8u_corba    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:giv-planner    文件:Test76.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
    if (currentObject == null || currentClassDesc == null)
    // XXX I18N, Logging needed.
    throw new NotActiveException("defaultWriteObjectDelegate");

    ObjectStreamField[] fields =
    currentClassDesc.getFieldsNoCopy();
    if (fields.length > 0) {
    outputClassFields(currentObject, currentClassDesc.forClass(),
              fields);
    }
    } catch(IOException ioe) {
    bridge.throwException(ioe);
}
}
项目:j2objc    文件:OldObjectOutputStreamTest.java   
public void test_putFields() throws Exception {
    /*
     * "SerializableTestHelper" is an object created for these tests with
     * two fields (Strings) and simple implementations of readObject and
     * writeObject which simply read and write the first field but not the
     * second one.
     */
    SerializableTestHelper sth;

    try {
        oos.putFields();
        fail("Test 1: NotActiveException expected.");
    } catch (NotActiveException e) {
        // Expected.
    }

    oos.writeObject(new SerializableTestHelper("Gabba", "Jabba"));
    oos.flush();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    sth = (SerializableTestHelper) (ois.readObject());
    assertEquals("Test 2: readFields or writeFields failed; first field not set.",
            "Gabba", sth.getText1());
    assertNull("Test 3: readFields or writeFields failed; second field should not have been set.",
            sth.getText2());
}
项目:infobip-open-jdk-8    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:infobip-open-jdk-8    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:In-the-Box-Fork    文件:ObjectInputStreamTest.java   
/**
 * @tests java.io.ObjectInputStream#defaultReadObject()
 */
public void test_defaultReadObject() throws Exception {
    // SM. This method may as well be private, as if called directly it
    // throws an exception.
    String s = "HelloWorld";
    oos.writeObject(s);
    oos.close();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    try {
        ois.defaultReadObject();
        fail("NotActiveException expected");
    } catch (NotActiveException e) {
        // Desired behavior
    } finally {
        ois.close();
    }
}
项目:In-the-Box-Fork    文件:ObjectInputStreamTest.java   
public void test_registerValidation() throws Exception {
    // Regression Test for Harmony-2402
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos);
    ObjectInputStream ois = new ObjectInputStream(
            new ByteArrayInputStream(baos.toByteArray()));

    try {
        ois.registerValidation(null, 256);
        fail("NotActiveException should be thrown");
    } catch (NotActiveException nae) {
        // expected
    }

    // Regression Test for Harmony-3916
    baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(new RegisterValidationClass());
    oos.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream fis = new ObjectInputStream(bais);
    // should not throw NotActiveException
    fis.readObject();
}
项目:In-the-Box-Fork    文件:NotActiveExceptionTest.java   
/**
 * @tests java.io.NotActiveException#NotActiveException()
 */
@TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "NotActiveException",
        args = {}
    )
public void test_Constructor() {
    try {
        if (true) // To avoid unreachable code compilation error.
            throw new NotActiveException();
        fail("Test 1: NotActiveException expected.");
    } catch (NotActiveException e) {
        assertNull("Test 2: Null expected for exceptions constructed without a message.",
                e.getMessage());
    }
}
项目:In-the-Box-Fork    文件:NotActiveExceptionTest.java   
/**
 * @tests java.io.NotActiveException#NotActiveException(java.lang.String)
 */
@TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "NotActiveException",
        args = {java.lang.String.class}
    )
public void test_ConstructorLjava_lang_String() {
    try {
        if (true) // To avoid unreachable code compilation error.
            throw new NotActiveException("Something went wrong.");
        fail("Test 1: NotActiveException expected.");
    } catch (NotActiveException e) {
        assertEquals("Test 2: Incorrect message;",
                "Something went wrong.", e.getMessage());
    }
}
项目:In-the-Box-Fork    文件:ObjectInputStreamTest.java   
/**
 * @tests java.io.ObjectInputStream#defaultReadObject()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "defaultReadObject",
    args = {}
)
public void test_defaultReadObject() throws Exception {
    // Test for method void java.io.ObjectInputStream.defaultReadObject()
    // SM. This method may as well be private, as if called directly it
    // throws an exception.
    String s = testString;
    oos.writeObject(s);
    oos.close();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    try {
        ois.defaultReadObject();
        fail("NotActiveException expected");
    } catch (NotActiveException e) {
        // Desired behavior
    } finally {
        ois.close();
    }
}
项目:In-the-Box-Fork    文件:ObjectInputStreamTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "registerValidation",
    args = {java.io.ObjectInputValidation.class, int.class}
)
public void test_registerValidation() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos);
    ObjectInputStream ois = new ObjectInputStream(
            new ByteArrayInputStream(baos.toByteArray()));

    try {
        ois.registerValidation(null, 256);
        fail("NotActiveException should be thrown");
    } catch (NotActiveException nae) {
        // expected
    }
}
项目:red5-websocket    文件:SecureWebSocketConfiguration.java   
public SslFilter getSslFilter() throws Exception {
    if (keystoreFile == null || truststoreFile == null) {
        throw new NotActiveException("Keystore or truststore are null");
    }
    SSLContext context = getSslContext();
    if (context == null) {
        throw new NotActiveException("SSLContext is null");
    }
    // create the ssl filter using server mode
    SslFilter sslFilter = new SslFilter(context);
    if (cipherSuites != null) {
        sslFilter.setEnabledCipherSuites(cipherSuites);
    }
    if (protocols != null) {
        if (log.isDebugEnabled()) {
            log.debug("Using these protocols: {}", Arrays.toString(protocols));
        }
        sslFilter.setEnabledProtocols(protocols);
    }
    return sslFilter;
}
项目:openjdk-source-code-learn    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:openjdk-source-code-learn    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:OLD-OpenJDK8    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:OLD-OpenJDK8    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:cn1    文件:ObjectInputStreamTest.java   
/**
 * @tests java.io.ObjectInputStream#defaultReadObject()
 */
public void test_defaultReadObject() throws Exception {
    // SM. This method may as well be private, as if called directly it
    // throws an exception.
    String s = "HelloWorld";
    oos.writeObject(s);
    oos.close();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    try {
        ois.defaultReadObject();
        fail("NotActiveException expected");
    } catch (NotActiveException e) {
        // Desired behavior
    } finally {
        ois.close();
    }
}
项目:cn1    文件:ObjectInputStreamTest.java   
public void test_registerValidation() throws Exception {
    // Regression Test for Harmony-2402
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos);
    ObjectInputStream ois = new ObjectInputStream(
            new ByteArrayInputStream(baos.toByteArray()));

    try {
        ois.registerValidation(null, 256);
        fail("NotActiveException should be thrown");
    } catch (NotActiveException nae) {
        // expected
    }

    // Regression Test for Harmony-3916
    baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(new RegisterValidationClass());
    oos.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream fis = new ObjectInputStream(bais);
    // should not throw NotActiveException
    fis.readObject();
}
项目:openjdk-orb    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:openjdk-orb    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:freeVM    文件:ObjectInputStreamTest.java   
/**
 * @tests java.io.ObjectInputStream#defaultReadObject()
 */
public void test_defaultReadObject() throws Exception {
    // Test for method void java.io.ObjectInputStream.defaultReadObject()
    // SM. This method may as well be private, as if called directly it
    // throws an exception.
    String s = "HelloWorld";
    oos.writeObject(s);
    oos.close();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    try {
        ois.defaultReadObject();
        fail("NotActiveException expected");
    } catch (NotActiveException e) {
        // Desired behavior
    } finally {
        ois.close();
    }
}
项目:freeVM    文件:ObjectInputStreamTest.java   
/**
 * @tests java.io.ObjectInputStream#defaultReadObject()
 */
public void test_defaultReadObject() throws Exception {
    // SM. This method may as well be private, as if called directly it
    // throws an exception.
    String s = "HelloWorld";
    oos.writeObject(s);
    oos.close();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    try {
        ois.defaultReadObject();
        fail("NotActiveException expected");
    } catch (NotActiveException e) {
        // Desired behavior
    } finally {
        ois.close();
    }
}
项目:freeVM    文件:ObjectInputStreamTest.java   
public void test_registerValidation() throws Exception {
    // Regression Test for Harmony-2402
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos);
    ObjectInputStream ois = new ObjectInputStream(
            new ByteArrayInputStream(baos.toByteArray()));

    try {
        ois.registerValidation(null, 256);
        fail("NotActiveException should be thrown");
    } catch (NotActiveException nae) {
        // expected
    }

    // Regression Test for Harmony-3916
    baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(new RegisterValidationClass());
    oos.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream fis = new ObjectInputStream(bais);
    // should not throw NotActiveException
    fis.readObject();
}
项目:openjdk-icedtea7    文件:IIOPOutputStream.java   
/**
 * Override the actions of the final method "defaultWriteObject()"
 * in ObjectOutputStream.
 * @since     JDK1.1.6
 */
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
    try {
        if (currentObject == null || currentClassDesc == null)
            // XXX I18N, Logging needed.
            throw new NotActiveException("defaultWriteObjectDelegate");

        ObjectStreamField[] fields =
            currentClassDesc.getFieldsNoCopy();
        if (fields.length > 0) {
            outputClassFields(currentObject, currentClassDesc.forClass(),
                              fields);
        }
    } catch(IOException ioe) {
        bridge.throwException(ioe);
    }
}
项目:openjdk-icedtea7    文件:InputStreamHook.java   
public ObjectInputStream.GetField readFields()
    throws IOException, ClassNotFoundException, NotActiveException {

    HashMap fieldValueMap = new HashMap();

    // We were treating readFields same as defaultReadObject. It is
    // incorrect if the state is readOptionalData. If this line
    // is uncommented, it will throw a stream corrupted exception.
    // _REVISIT_: The ideal fix would be to add a new state. In
    // writeObject user may do one of the following
    // 1. Call defaultWriteObject()
    // 2. Put out optional fields
    // 3. Call writeFields
    // We have the state defined for (1) and (2) but not for (3), so
    // we should ideally introduce a new state for 3 and have the
    // beginDefaultReadObject do nothing.
    //readObjectState.beginDefaultReadObject(this);

    readFields(fieldValueMap);

    readObjectState.endDefaultReadObject(this);

    return new HookGetFields(fieldValueMap);
}
项目:red5-mobileconsole    文件:RTMPSMinaIoHandler.java   
/** {@inheritDoc} */
@Override
public void sessionOpened(IoSession session) throws Exception {
    if (password == null || keystore == null) {
        throw new NotActiveException("Keystore or password are null");
    }
    // START OF NATIVE SSL STUFF
    SSLContext context = SSLContext.getInstance("TLS"); //TLS, TLSv1, TLSv1.1
    // The reference implementation only supports X.509 keys
    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    //initialize the key manager
    kmf.init(getKeyStore(), password);
    // initialize the ssl context
    context.init(kmf.getKeyManagers(), null, null);
    //create the ssl filter using server mode
    SslFilter sslFilter = new SslFilter(context);
    if (sslFilter != null) {
        session.getFilterChain().addFirst("sslFilter", sslFilter);
    }
    // END OF NATIVE SSL STUFF
    super.sessionOpened(session);
}
项目:lams    文件:XStream.java   
/**
 * Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
 * <p>
 * Because an ObjectOutputStream can contain multiple items and XML only allows a single root node, the stream must
 * be written inside an enclosing node.
 * </p>
 * <p>
 * It is necessary to call ObjectOutputStream.close() when done, otherwise the stream will be incomplete.
 * </p>
 * <h3>Example</h3>
 * 
 * <pre>
 *  ObjectOutputStream out = xstream.createObjectOutputStream(aWriter, &quot;things&quot;);
 *   out.writeInt(123);
 *   out.writeObject(&quot;Hello&quot;);
 *   out.writeObject(someObject)
 *   out.close();
 * </pre>
 * 
 * @param writer The writer to serialize the objects to.
 * @param rootNodeName The name of the root node enclosing the stream of objects.
 * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
 * @since 1.0.3
 */
@SuppressWarnings("resource")
public ObjectOutputStream createObjectOutputStream(final HierarchicalStreamWriter writer, final String rootNodeName)
        throws IOException {
    final StatefulWriter statefulWriter = new StatefulWriter(writer);
    statefulWriter.startNode(rootNodeName, null);
    return new CustomObjectOutputStream(new CustomObjectOutputStream.StreamCallback() {
        @Override
        public void writeToStream(final Object object) {
            marshal(object, statefulWriter);
        }

        @Override
        public void writeFieldsToStream(final Map<String, Object> fields) throws NotActiveException {
            throw new NotActiveException("not in call to writeObject");
        }

        @Override
        public void defaultWriteObject() throws NotActiveException {
            throw new NotActiveException("not in call to writeObject");
        }

        @Override
        public void flush() {
            statefulWriter.flush();
        }

        @Override
        public void close() {
            if (statefulWriter.state() != StatefulWriter.STATE_CLOSED) {
                statefulWriter.endNode();
                statefulWriter.close();
            }
        }
    });
}
项目:lams    文件:XStream.java   
/**
 * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream. <h3>Example</h3>
 * 
 * <pre>
 * ObjectInputStream in = xstream.createObjectOutputStream(aReader);
 * int a = out.readInt();
 * Object b = out.readObject();
 * Object c = out.readObject();
 * </pre>
 * 
 * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String)
 * @since 1.0.3
 */
public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader reader) throws IOException {
    return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() {
        @Override
        public Object readFromStream() throws EOFException {
            if (!reader.hasMoreChildren()) {
                throw new EOFException();
            }
            reader.moveDown();
            final Object result = unmarshal(reader);
            reader.moveUp();
            return result;
        }

        @Override
        public Map<String, Object> readFieldsFromStream() throws IOException {
            throw new NotActiveException("not in call to readObject");
        }

        @Override
        public void defaultReadObject() throws NotActiveException {
            throw new NotActiveException("not in call to readObject");
        }

        @Override
        public void registerValidation(final ObjectInputValidation validation, final int priority)
                throws NotActiveException {
            throw new NotActiveException("stream inactive");
        }

        @Override
        public void close() {
            reader.close();
        }
    }, classLoaderReference);
}
项目:OpenJSharp    文件:InputStreamHook.java   
public void defaultReadObject()
    throws IOException, ClassNotFoundException, NotActiveException
{
    readObjectState.beginDefaultReadObject(this);

    defaultReadObjectDelegate();

    readObjectState.endDefaultReadObject(this);
}
项目:openjdk-jdk10    文件:OutputStreamHook.java   
public void writeFields()
    throws IOException {

    writeObjectState.defaultWriteObject(this);
    if (putFields != null) {
        putFields.write(this);
    } else {
        throw new NotActiveException("no current PutField object");
    }
}
项目:openjdk-jdk10    文件:InputStreamHook.java   
public void defaultReadObject()
    throws IOException, ClassNotFoundException, NotActiveException
{
    readObjectState.beginDefaultReadObject(this);

    defaultReadObjectDelegate();

    readObjectState.endDefaultReadObject(this);
}