Java 8 InvalidObjectException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 InvalidObjectException class.

This code example shows how to use the following methods:initCause
	s.defaultReadObject();
	// check invariants 
	try { 
	    validate(); 
	} catch (Exception e) {
	    InvalidObjectException x = new InvalidObjectException(
		    e.getMessage());
	    x.initCause(e);
	    throw x;
	} 
    } 
 
    /** 
     * Gets a string representation of this option useful for logging 
     * and not intended for display.  The exact details of the 
     * representation are unspecified and subject to change, but the 
     * following format may be regarded as typical: 
     * <pre><code> 
     * class-name[property1 = value1, property2 = value2] 
     * </code></pre> 
6
CodeRank
This code example shows how to use the following methods:initCause
        { 
            return SerializationSupport.readResolve(serviceId);
        } 
        catch (Exception ex)
        { 
            ObjectStreamException ose = new InvalidObjectException(ex.getMessage());
            ose.initCause(ex);
 
            throw ose;
        } 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
    } 
 
    // have a readObject that throws to prevent spoofing 
    private void readObject(ObjectInputStream stream) throws InvalidObjectException {
        throw new InvalidObjectException("Cannot readObject, serialization proxy required");
    } 
 
 
    private static Date getBundleLongAsDate(Bundle bundle, String key, Date dateBase) {
        if (bundle == null) {
            return null; 
        } 
 
        long secondsFromBase = Long.MIN_VALUE;
 
        Object secondsObject = bundle.get(key);
        if (secondsObject instanceof Long) {
            secondsFromBase = (Long) secondsObject;
        } else if (secondsObject instanceof String) {
            try { 
5
CodeRank
This code example shows how to use the following methods:initCause
    protected final void writeState(ObjectOutputStream out) throws IOException {
        int pageSize;
        try { 
            pageSize = pageSizeField.getInt(this);
        } catch (IllegalAccessException e) {
            InvalidObjectException ioe = new InvalidObjectException("Cannot set page size");
            ioe.initCause(e);
            throw ioe;
        } 
 
        // 
        out.writeInt(pageSize);
        out.writeInt(currentPage_);
    } 
 
    protected final void readState(ObjectInputStream in) throws IOException {
        try { 
            pageSizeField.setInt(this, in.readInt());
        } catch (IllegalAccessException e) {
            InvalidObjectException ioe = new InvalidObjectException("Cannot set page size");
5
CodeRank
This code example shows how to use the following methods:
 
		ObjectInputStream.GetField fields = stream.readFields(); 
		Expression[] expressionArray = (Expression[]) fields.get("values", null); 
 
		if (expressionArray == null) { 
			throw new InvalidObjectException("Cannot create a ListLiteral with a null value list"); 
		} 
		values = new ArrayList(Arrays.asList(expressionArray)); 
	} 
 
	/** 
	 * Returns a string representation of the object. 
	 *  
	 * @return a <code>String</code> representation of this expression 
	 */ 
	public String toString() { 
		return values.toString(); 
	} 
 
	/** 
4
CodeRank
This code example shows how to use the following methods:
			throw new NullPointerException("cls");
		 
		Object obj = deserialize(in, cls);
		if (!cls.isInstance(obj))
		{ 
			throw new InvalidObjectException("type of deserialized instance not of required class.");
		} 
		 
		return obj; 
	} 
	 
	/** 
	 * Deserializes an object from the given <code>InputStream</code>. 
	 * The deserialization is delegated to an <code> 
	 * ObjectInputStream</code> instance.  
	 *  
	 * @param in	The <code>InputStream</code> to deserialize an object 
	 *				from. 
	 *  
	 * @return The object deserialized from the stream.  
4
CodeRank
This code example shows how to use the following methods:
    stream.defaultReadObject();
    Comparator<Object> valueComparator =
        (Comparator<Object>) stream.readObject();
    int keyCount = stream.readInt();
    if (keyCount < 0) {
      throw new InvalidObjectException("Invalid key count " + keyCount);
    } 
    ImmutableMap.Builder<Object, ImmutableSet<Object>> builder
        = ImmutableMap.builder(); 
    int tmpSize = 0;
 
    for (int i = 0; i < keyCount; i++) {
      Object key = stream.readObject();
      int valueCount = stream.readInt();
      if (valueCount <= 0) {
        throw new InvalidObjectException("Invalid value count " + valueCount);
      } 
 
      Object[] array = new Object[valueCount];
      for (int j = 0; j < valueCount; j++) {
4
CodeRank
This code example shows how to use the following methods:
	 *            the input stream to read serialized objects from 
	 */ 
	private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
		stream.defaultReadObject();
		if (name == null) {
			throw new InvalidObjectException("Cannot create an Identifier with a null name");
		} 
	} 
 
	/** 
	 * Resolves the current expression, possibly into a different expression 
	 * object. This is loosely equivalent to the serialization protocol's 
	 * <code>readResolve</code> method. Situations where this may be used are: 
	 * <ul> 
	 * <li>Caching frequently-used expression objects</li> 
	 * <li>Evaluating constant expressions, and returning a constant reference</li> 
	 * </ul> 
	 */ 
	public Expression resolveExpression() { 
		return ExpressionCache.cacheExpression(this);
4
CodeRank
This code example shows how to use the following methods:
 
		ObjectInputStream.GetField fields = stream.readFields(); 
		String value = (String) fields.get("stringValue", null); 
 
		if (value == null) { 
			throw new InvalidObjectException("Cannot create a StringLiteral with a null value "); 
		} 
 
		// Recreate the original fields 
		this.value = new FastScalar(value); 
	} 
 
	/** 
	 * For serialization, write this object as a single String object. 
	 *  
	 * @param stream 
	 *            the output stream to write this object to 
	 */ 
	private void writeObject(ObjectOutputStream stream) throws IOException { 
		ObjectOutputStream.PutField fields = stream.putFields(); 
4
CodeRank
This code example shows how to use the following methods:
	 *            the input stream to read serialized objects from 
	 */ 
	private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { 
		stream.defaultReadObject(); 
		if (transformVariable == null) { 
			throw new InvalidObjectException("Cannot create a TransformInstruction with a null variable"); 
		} 
	} 
} 
4
CodeRank
See Code Examples for Java 8 InvalidObjectException Methods: