Package java.io

Examples of java.io.InvalidObjectException


   throws IOException, ClassNotFoundException {
   s.defaultReadObject();
 
   // Check that our invariants are satisfied
   if (port < 0 || port > 0xFFFF) {
       throw new InvalidObjectException("port out of range:" + port);
   }
  
   if (hostname == null && addr == null) {
       throw new InvalidObjectException("hostname and addr " +
                "can't both be null");
   }
    }
View Full Code Here


  stream.defaultReadObject();

  try {
      compiledPattern = compile(pattern);
  } catch (Exception e) {
      throw new InvalidObjectException("invalid pattern");
  }

  if (serialVersionOnStream < 1) {
      // didn't have defaultCenturyStart field
      initializeDefaultCentury();
View Full Code Here

    /**
     * @throws InvalidObjectException unconditionally
     **/
    private void readObjectNoData() throws InvalidObjectException {
        throw new InvalidObjectException("no data in stream; class: " +
                                         this.getClass().getName());
    }
View Full Code Here

            minimumFractionDigits = minFractionDigits;
        }
        if (minimumIntegerDigits > maximumIntegerDigits ||
            minimumFractionDigits > maximumFractionDigits ||
            minimumIntegerDigits < 0 || minimumFractionDigits < 0) {
            throw new InvalidObjectException("Digit count range invalid");
        }
        serialVersionOnStream = currentSerialVersion;
    }
View Full Code Here

         * @throws InvalidObjectException if the constant could not be resolved.
         * @return resolved NumberFormat.Field constant
         */
        protected Object readResolve() throws InvalidObjectException {
            if (this.getClass() != NumberFormat.Field.class) {
                throw new InvalidObjectException("subclass didn't correctly implement readResolve");
            }

            Object instance = instanceMap.get(getName());
            if (instance != null) {
                return instance;
            } else {
                throw new InvalidObjectException("unknown attribute name");
            }
        }
View Full Code Here

  if (activator instanceof RemoteObject) {
      ref = ((RemoteObject) activator).getRef();
  } else if (Proxy.isProxyClass(activator.getClass())) {
      InvocationHandler handler = Proxy.getInvocationHandler(activator);
      if (!(handler instanceof RemoteObjectInvocationHandler)) {
    throw new InvalidObjectException(
        "unexpected invocation handler");
      }
      ref = ((RemoteObjectInvocationHandler) handler).getRef();
     
  } else {
      throw new InvalidObjectException("unexpected activator type");
  }
  out.writeUTF(ref.getRefClass(out));
  ref.writeExternal(out);
    }
View Full Code Here

               new Class<?>[] { Activator.class },
               new RemoteObjectInvocationHandler(ref));

  } catch (InstantiationException e) {
      throw (IOException)
    new InvalidObjectException(
        "Unable to create remote reference").initCause(e);
  } catch (IllegalAccessException e) {
      throw (IOException)
    new InvalidObjectException(
        "Unable to create remote reference").initCause(e);
  }
    }
View Full Code Here

        /**
         * Resolves instances being deserialized to the predefined constants.
         */
        protected Object readResolve() throws InvalidObjectException {
            if (this.getClass() != Attribute.class) {
                throw new InvalidObjectException("subclass didn't correctly implement readResolve");
            }

            Attribute instance = (Attribute) instanceMap.get(getName());
            if (instance != null) {
                return instance;
            } else {
                throw new InvalidObjectException("unknown attribute name");
            }
        }
View Full Code Here

  private void readObject(ObjectInputStream stream)
      throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    int keyCount = stream.readInt();
    if (keyCount < 0) {
      throw new InvalidObjectException("Invalid key count " + keyCount);
    }
    ImmutableMap.Builder<Object, ImmutableList<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++) {
        array[j] = stream.readObject();
      }
      builder.put(key, ImmutableList.copyOf(array));
      tmpSize += valueCount;
    }

    ImmutableMap<Object, ImmutableList<Object>> tmpMap;
    try {
      tmpMap = builder.build();
    } catch (IllegalArgumentException e) {
      throw (InvalidObjectException)
          new InvalidObjectException(e.getMessage()).initCause(e);
    }

    FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
    FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
  }
View Full Code Here

  private void readObject(ObjectInputStream stream)
      throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    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++) {
        array[j] = stream.readObject();
      }
      ImmutableSet<Object> valueSet = ImmutableSet.copyOf(array);
      if (valueSet.size() != array.length) {
        throw new InvalidObjectException(
            "Duplicate key-value pairs exist for key " + key);
      }
      builder.put(key, valueSet);
      tmpSize += valueCount;
    }

    ImmutableMap<Object, ImmutableSet<Object>> tmpMap;
    try {
      tmpMap = builder.build();
    } catch (IllegalArgumentException e) {
      throw (InvalidObjectException)
          new InvalidObjectException(e.getMessage()).initCause(e);
    }

    FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
    FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
  }
View Full Code Here

TOP

Related Classes of java.io.InvalidObjectException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.