java.io.OptionalDataException Java Examples

The following examples show how to use java.io.OptionalDataException. 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: IIOPInputStream.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #2
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #3
Source File: IIOPInputStream.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #4
Source File: IIOPInputStream.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #5
Source File: EntitySerializationExceptionHandler.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean canHandle(String className, String message, @Nullable Throwable throwable) {
    Throwable cause = throwable != null ? throwable.getCause() : null;
    if (cause == null) {
        return false;
    }

    if (cause instanceof ClassCastException && checkClassCastExceptionStack(cause.getStackTrace())) {
        return true;
    }

    if (cause instanceof OptionalDataException && checkOptionalDataExceptionStack(cause.getStackTrace())) {
        return true;
    }
    return false;
}
 
Example #6
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #7
Source File: IIOPInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #8
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #9
Source File: IIOPInputStream.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #10
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private OptionalDataException createOptionalDataException() {
    try {
        OptionalDataException result
            = (OptionalDataException)
               OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] {
                   Boolean.TRUE });

        if (result == null)
            // XXX I18N, logging needed.
            throw new Error("Created null OptionalDataException");

        return result;

    } catch (Exception ex) {
        // XXX I18N, logging needed.
        throw new Error("Couldn't create OptionalDataException", ex);
    }
}
 
Example #11
Source File: DataFlavor.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Restores this <code>DataFlavor</code> from a Serialized state.
 */

public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
    String rcn = null;
     mimeType = (MimeType)is.readObject();

     if (mimeType != null) {
         humanPresentableName =
             mimeType.getParameter("humanPresentableName");
         mimeType.removeParameter("humanPresentableName");
         rcn = mimeType.getParameter("class");
         if (rcn == null) {
             throw new IOException("no class parameter specified in: " +
                                   mimeType);
         }
     }

     try {
         representationClass = (Class)is.readObject();
     } catch (OptionalDataException ode) {
         if (!ode.eof || ode.length != 0) {
             throw ode;
         }
         // Ensure backward compatibility.
         // Old versions didn't write the representation class to the stream.
         if (rcn != null) {
             representationClass =
                 DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
         }
     }
}
 
Example #12
Source File: ReflectionFactory.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Return the accessible constructor for OptionalDataException signaling eof.
 * @returns the eof constructor for OptionalDataException
 */
public final Constructor<OptionalDataException> newOptionalDataExceptionForSerialization() {
    try {
        Constructor<OptionalDataException> boolCtor =
                OptionalDataException.class.getDeclaredConstructor(Boolean.TYPE);
        boolCtor.setAccessible(true);
        return boolCtor;
    } catch (NoSuchMethodException ex) {
        throw new InternalError("Constructor not found", ex);
    }
}
 
Example #13
Source File: IIOPInputStream.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static Constructor getOptDataExceptionCtor() {

        try {

            Constructor result =

                (Constructor) AccessController.doPrivileged(
                                    new PrivilegedExceptionAction() {
                    public java.lang.Object run()
                        throws NoSuchMethodException,
                        SecurityException {

                        Constructor boolCtor
                            = OptionalDataException.class.getDeclaredConstructor(
                                                               new Class[] {
                                Boolean.TYPE });

                        boolCtor.setAccessible(true);

                        return boolCtor;
                    }});

            if (result == null)
                // XXX I18N, logging needed.
                throw new Error("Unable to find OptionalDataException constructor");

            return result;

        } catch (Exception ex) {
            // XXX I18N, logging needed.
            throw new ExceptionInInitializerError(ex);
        }
    }
 
Example #14
Source File: DataFlavor.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Restores this {@code DataFlavor} from a Serialized state.
 */
public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
    String rcn = null;
    mimeType = (MimeType)is.readObject();

    if (mimeType != null) {
        humanPresentableName =
            mimeType.getParameter("humanPresentableName");
        mimeType.removeParameter("humanPresentableName");
        rcn = mimeType.getParameter("class");
        if (rcn == null) {
            throw new IOException("no class parameter specified in: " +
                                  mimeType);
        }
    }

    try {
        representationClass = (Class)is.readObject();
    } catch (OptionalDataException ode) {
        if (!ode.eof || ode.length != 0) {
            throw ode;
        }
        // Ensure backward compatibility.
        // Old versions didn't write the representation class to the stream.
        if (rcn != null) {
            representationClass =
                DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
        }
    }
}
 
Example #15
Source File: BuilderSerializer.java    From Serial with Apache License 2.0 5 votes vote down vote up
private void deserialize(@NotNull SerializationContext context, @NotNull SerializerInput input, @NotNull B builder,
        int versionNumber)
        throws IOException, ClassNotFoundException {
    try {
        //noinspection BlacklistedMethod
        deserializeToBuilder(context, input, builder, versionNumber);
    } catch (OptionalDataException | EOFException | OptionalFieldException ignore) {
        // This may happen when reading optional fields. The builder should already
        // contain all the available fields, so just ignore the exception.
    }
}
 
Example #16
Source File: DataFlavor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restores this {@code DataFlavor} from a Serialized state.
 */
public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
    String rcn = null;
    mimeType = (MimeType)is.readObject();

    if (mimeType != null) {
        humanPresentableName =
            mimeType.getParameter("humanPresentableName");
        mimeType.removeParameter("humanPresentableName");
        rcn = mimeType.getParameter("class");
        if (rcn == null) {
            throw new IOException("no class parameter specified in: " +
                                  mimeType);
        }
    }

    try {
        representationClass = (Class)is.readObject();
    } catch (OptionalDataException ode) {
        if (!ode.eof || ode.length != 0) {
            throw ode;
        }
        // Ensure backward compatibility.
        // Old versions didn't write the representation class to the stream.
        if (rcn != null) {
            representationClass =
                DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
        }
    }
}
 
Example #17
Source File: DataFlavor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restores this <code>DataFlavor</code> from a Serialized state.
 */

public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
    String rcn = null;
     mimeType = (MimeType)is.readObject();

     if (mimeType != null) {
         humanPresentableName =
             mimeType.getParameter("humanPresentableName");
         mimeType.removeParameter("humanPresentableName");
         rcn = mimeType.getParameter("class");
         if (rcn == null) {
             throw new IOException("no class parameter specified in: " +
                                   mimeType);
         }
     }

     try {
         representationClass = (Class)is.readObject();
     } catch (OptionalDataException ode) {
         if (!ode.eof || ode.length != 0) {
             throw ode;
         }
         // Ensure backward compatibility.
         // Old versions didn't write the representation class to the stream.
         if (rcn != null) {
             representationClass =
                 DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
         }
     }
}
 
Example #18
Source File: ReflectionFactoryTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test the constructor of OptionalDataExceptions.
 */
@Test
static void newOptionalDataException() {
    OptionalDataException ode = factory.newOptionalDataExceptionForSerialization(true);
    Assert.assertTrue(ode.eof, "eof wrong");
    ode = factory.newOptionalDataExceptionForSerialization(false);
    Assert.assertFalse(ode.eof, "eof wrong");

}
 
Example #19
Source File: DataFlavor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restores this <code>DataFlavor</code> from a Serialized state.
 */

public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
    String rcn = null;
     mimeType = (MimeType)is.readObject();

     if (mimeType != null) {
         humanPresentableName =
             mimeType.getParameter("humanPresentableName");
         mimeType.removeParameter("humanPresentableName");
         rcn = mimeType.getParameter("class");
         if (rcn == null) {
             throw new IOException("no class parameter specified in: " +
                                   mimeType);
         }
     }

     try {
         representationClass = (Class)is.readObject();
     } catch (OptionalDataException ode) {
         if (!ode.eof || ode.length != 0) {
             throw ode;
         }
         // Ensure backward compatibility.
         // Old versions didn't write the representation class to the stream.
         if (rcn != null) {
             representationClass =
                 DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
         }
     }
}
 
Example #20
Source File: IIOPInputStream.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static Constructor getOptDataExceptionCtor() {

        try {

            Constructor result =

                (Constructor) AccessController.doPrivileged(
                                    new PrivilegedExceptionAction() {
                    public java.lang.Object run()
                        throws NoSuchMethodException,
                        SecurityException {

                        Constructor boolCtor
                            = OptionalDataException.class.getDeclaredConstructor(
                                                               new Class[] {
                                Boolean.TYPE });

                        boolCtor.setAccessible(true);

                        return boolCtor;
                    }});

            if (result == null)
                // XXX I18N, logging needed.
                throw new Error("Unable to find OptionalDataException constructor");

            return result;

        } catch (Exception ex) {
            // XXX I18N, logging needed.
            throw new ExceptionInInitializerError(ex);
        }
    }
 
Example #21
Source File: ReflectionFactory.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a new OptionalDataException with {@code eof} set to {@code true}
 * or {@code false}.
 * @param bool the value of {@code eof} in the created OptionalDataException
 * @return  a new OptionalDataException
 */
public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) {
    try {
        Constructor<OptionalDataException> boolCtor =
                OptionalDataException.class.getDeclaredConstructor(Boolean.TYPE);
        boolCtor.setAccessible(true);
        return boolCtor.newInstance(bool);
    } catch (NoSuchMethodException | InstantiationException|
            IllegalAccessException|InvocationTargetException ex) {
        throw new InternalError("unable to create OptionalDataException", ex);
    }
}
 
Example #22
Source File: ReflectionFactoryTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test the constructor of OptionalDataExceptions.
 */
@Test
static void newOptionalDataException() {
    OptionalDataException ode = factory.newOptionalDataExceptionForSerialization(true);
    Assert.assertTrue(ode.eof, "eof wrong");
    ode = factory.newOptionalDataExceptionForSerialization(false);
    Assert.assertFalse(ode.eof, "eof wrong");

}
 
Example #23
Source File: ReflectionFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a new OptionalDataException with {@code eof} set to {@code true}
 * or {@code false}.
 * @param bool the value of {@code eof} in the created OptionalDataException
 * @return  a new OptionalDataException
 */
public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) {
    Constructor<OptionalDataException> cons = delegate.newOptionalDataExceptionForSerialization();
    try {
        return cons.newInstance(bool);
    } catch (InstantiationException|IllegalAccessException|InvocationTargetException ex) {
        throw new InternalError("unable to create OptionalDataException", ex);
    }
}
 
Example #24
Source File: MailImpl.java    From james-project with Apache License 2.0 5 votes vote down vote up
/**
 * Fallback to Java deserialization if {@link MailImpl#setAttributesUsingJsonable(ObjectInputStream)} fails.
 */
@SuppressWarnings("unchecked")
private void setAttributesUsingJavaSerializable(ObjectInputStream in) throws IOException, ClassNotFoundException {
    // the following is under try/catch to be backwards compatible
    // with messages created with James version <= 2.2.0a8
    try {
        setAttributesRaw((Map<String, Object>) in.readObject());
    } catch (OptionalDataException ode) {
        if (ode.eof) {
            attributes = new HashMap<>();
        } else {
            throw ode;
        }
    }
}
 
Example #25
Source File: ReflectionFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a new OptionalDataException with {@code eof} set to {@code true}
 * or {@code false}.
 * @param bool the value of {@code eof} in the created OptionalDataException
 * @return  a new OptionalDataException
 */
public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) {
    try {
        Constructor<OptionalDataException> boolCtor =
                OptionalDataException.class.getDeclaredConstructor(Boolean.TYPE);
        boolCtor.setAccessible(true);
        return boolCtor.newInstance(bool);
    } catch (NoSuchMethodException | InstantiationException|
            IllegalAccessException|InvocationTargetException ex) {
        throw new InternalError("unable to create OptionalDataException", ex);
    }
}
 
Example #26
Source File: DataFlavor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restores this <code>DataFlavor</code> from a Serialized state.
 */

public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
    String rcn = null;
     mimeType = (MimeType)is.readObject();

     if (mimeType != null) {
         humanPresentableName =
             mimeType.getParameter("humanPresentableName");
         mimeType.removeParameter("humanPresentableName");
         rcn = mimeType.getParameter("class");
         if (rcn == null) {
             throw new IOException("no class parameter specified in: " +
                                   mimeType);
         }
     }

     try {
         representationClass = (Class)is.readObject();
     } catch (OptionalDataException ode) {
         if (!ode.eof || ode.length != 0) {
             throw ode;
         }
         // Ensure backward compatibility.
         // Old versions didn't write the representation class to the stream.
         if (rcn != null) {
             representationClass =
                 DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
         }
     }
}
 
Example #27
Source File: IIOPInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static Constructor getOptDataExceptionCtor() {

        try {

            Constructor result =

                (Constructor) AccessController.doPrivileged(
                                    new PrivilegedExceptionAction() {
                    public java.lang.Object run()
                        throws NoSuchMethodException,
                        SecurityException {

                        Constructor boolCtor
                            = OptionalDataException.class.getDeclaredConstructor(
                                                               new Class[] {
                                Boolean.TYPE });

                        boolCtor.setAccessible(true);

                        return boolCtor;
                    }});

            if (result == null)
                // XXX I18N, logging needed.
                throw new Error("Unable to find OptionalDataException constructor");

            return result;

        } catch (Exception ex) {
            // XXX I18N, logging needed.
            throw new ExceptionInInitializerError(ex);
        }
    }
 
Example #28
Source File: ReflectionFactoryTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test the constructor of OptionalDataExceptions.
 */
@Test
static void newOptionalDataException() {
    OptionalDataException ode = factory.newOptionalDataExceptionForSerialization(true);
    Assert.assertTrue(ode.eof, "eof wrong");
    ode = factory.newOptionalDataExceptionForSerialization(false);
    Assert.assertFalse(ode.eof, "eof wrong");

}
 
Example #29
Source File: ReflectionFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a new OptionalDataException with {@code eof} set to {@code true}
 * or {@code false}.
 * @param bool the value of {@code eof} in the created OptionalDataException
 * @return  a new OptionalDataException
 */
public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) {
    try {
        Constructor<OptionalDataException> boolCtor =
                OptionalDataException.class.getDeclaredConstructor(Boolean.TYPE);
        boolCtor.setAccessible(true);
        return boolCtor.newInstance(bool);
    } catch (NoSuchMethodException | InstantiationException|
            IllegalAccessException|InvocationTargetException ex) {
        throw new InternalError("unable to create OptionalDataException", ex);
    }
}
 
Example #30
Source File: FakeMail.java    From james-project with Apache License 2.0 5 votes vote down vote up
/**
 * Read the FakeMail from an <code>ObjectInputStream</code>.
 */
@SuppressWarnings("unchecked")
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    try {
        Object obj = in.readObject();
        if (obj == null) {
            sender = null;
        } else if (obj instanceof String) {
            sender = new MailAddress((String) obj);
        } else if (obj instanceof MailAddress) {
            sender = (MailAddress) obj;
        }
    } catch (ParseException pe) {
        throw new IOException("Error parsing sender address: " + pe.getMessage());
    }
    recipients = (Collection<MailAddress>) in.readObject();
    state = (String) in.readObject();
    errorMessage = (String) in.readObject();
    name = (String) in.readObject();
    remoteHost = (String) in.readObject();
    remoteAddr = (String) in.readObject();
    setLastUpdated((Date) in.readObject());
    // the following is under try/catch to be backwards compatible
    // with messages created with James version <= 2.2.0a8
    try {
        setAttributesRaw((Map<String, Object>) in.readObject());
    } catch (OptionalDataException ode) {
        if (ode.eof) {
            attributes = new HashMap<>();
        } else {
            throw ode;
        }
    }
    perRecipientHeaders = (PerRecipientHeaders) in.readObject();
}