Java 类java.io.InvalidObjectException 实例源码

项目:OpenJSharp    文件:BatchUpdateException.java   
/**
 * readObject is called to restore the state of the
 * {@code BatchUpdateException} from a stream.
 */
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {

   ObjectInputStream.GetField fields = s.readFields();
   int[] tmp = (int[])fields.get("updateCounts", null);
   long[] tmp2 = (long[])fields.get("longUpdateCounts", null);
   if(tmp != null && tmp2 != null && tmp.length != tmp2.length)
       throw new InvalidObjectException("update counts are not the expected size");
   if (tmp != null)
       updateCounts = tmp.clone();
   if (tmp2 != null)
       longUpdateCounts = tmp2.clone();
   if(updateCounts == null && longUpdateCounts != null)
       updateCounts = copyUpdateCount(longUpdateCounts);
   if(longUpdateCounts == null && updateCounts != null)
       longUpdateCounts = copyUpdateCount(updateCounts);

}
项目:openjdk-jdk10    文件:URL.java   
private URL fabricateNewURL()
            throws InvalidObjectException {
    // create URL string from deserialized object
    URL replacementURL = null;
    String urlString = tempState.reconstituteUrlString();

    try {
        replacementURL = new URL(urlString);
    } catch (MalformedURLException mEx) {
        resetState();
        InvalidObjectException invoEx = new InvalidObjectException(
                "Malformed URL:  " + urlString);
        invoEx.initCause(mEx);
        throw invoEx;
    }
    replacementURL.setSerializedHashCode(tempState.getHashCode());
    resetState();
    return replacementURL;
}
项目:jdk8u-jdk    文件:InetSocketAddress.java   
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    // Don't call defaultReadObject()
    ObjectInputStream.GetField oisFields = in.readFields();
    final String oisHostname = (String)oisFields.get("hostname", null);
    final InetAddress oisAddr = (InetAddress)oisFields.get("addr", null);
    final int oisPort = oisFields.get("port", -1);

    // Check that our invariants are satisfied
    checkPort(oisPort);
    if (oisHostname == null && oisAddr == null)
        throw new InvalidObjectException("hostname and addr " +
                                         "can't both be null");

    InetSocketAddressHolder h = new InetSocketAddressHolder(oisHostname,
                                                            oisAddr,
                                                            oisPort);
    UNSAFE.putObject(this, FIELDS_OFFSET, h);
}
项目:openjdk-jdk10    文件:IIOPInputStream.java   
private static void setCharField(Object o, Class<?> c, String fieldName, char v)
{
    try {
        Field fld = getDeclaredField( c, fieldName ) ;
        if ((fld != null) && (fld.getType() == Character.TYPE)) {
            long key = bridge.objectFieldOffset( fld ) ;
            bridge.putChar( o, key, v ) ;
        } else {
            throw new InvalidObjectException("Field Type mismatch");
        }
    } catch (Exception e) {
        if (o != null) {
            throw utilWrapper.errorSetCharField( e, fieldName,
                o.toString(),
                new Character(v) ) ;
        } else {
            throw utilWrapper.errorSetCharField( e, fieldName,
                "null " + c.getName() + " object",
                new Character(v) ) ;
        }
    }
}
项目:jdk8u-jdk    文件:DefaultMXBeanMappingFactory.java   
@Override
final Object fromNonNullOpenValue(Object openValue)
        throws InvalidObjectException {
    final Object[] openArray = (Object[]) openValue;
    final Type javaType = getJavaType();
    final Object[] valueArray;
    final Type componentType;
    if (javaType instanceof GenericArrayType) {
        componentType =
            ((GenericArrayType) javaType).getGenericComponentType();
    } else if (javaType instanceof Class<?> &&
               ((Class<?>) javaType).isArray()) {
        componentType = ((Class<?>) javaType).getComponentType();
    } else {
        throw new IllegalArgumentException("Not an array: " +
                                           javaType);
    }
    valueArray = (Object[]) Array.newInstance((Class<?>) componentType,
                                              openArray.length);
    for (int i = 0; i < openArray.length; i++)
        valueArray[i] = elementMapping.fromOpenValue(openArray[i]);
    return valueArray;
}
项目:jdk8u-jdk    文件:URL.java   
private URL fabricateNewURL()
            throws InvalidObjectException {
    // create URL string from deserialized object
    URL replacementURL = null;
    String urlString = tempState.reconstituteUrlString();

    try {
        replacementURL = new URL(urlString);
    } catch (MalformedURLException mEx) {
        resetState();
        InvalidObjectException invoEx = new InvalidObjectException(
                "Malformed URL: " + urlString);
        invoEx.initCause(mEx);
        throw invoEx;
    }
    replacementURL.setSerializedHashCode(tempState.getHashCode());
    resetState();
    return replacementURL;
}
项目:openjdk-jdk10    文件:InetSocketAddress.java   
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    // Don't call defaultReadObject()
    ObjectInputStream.GetField oisFields = in.readFields();
    final String oisHostname = (String)oisFields.get("hostname", null);
    final InetAddress oisAddr = (InetAddress)oisFields.get("addr", null);
    final int oisPort = oisFields.get("port", -1);

    // Check that our invariants are satisfied
    checkPort(oisPort);
    if (oisHostname == null && oisAddr == null)
        throw new InvalidObjectException("hostname and addr " +
                                         "can't both be null");

    InetSocketAddressHolder h = new InetSocketAddressHolder(oisHostname,
                                                            oisAddr,
                                                            oisPort);
    UNSAFE.putObject(this, FIELDS_OFFSET, h);
}
项目:CommonInformationSpace    文件:OtherContentConnectorCoreExt.java   
/**
 * This message is called by the ConnectorCore when a message was receive. It will be translatet to the Application
 * representation and the translatet message if send via the registered callback to the application.
 * 
 * @param msg
 * @throws InvalidObjectException
 */
public void msgReceived(CISPayload payload) throws InvalidObjectException {
    log.info("--> messageReceived");

    if (payload instanceof CISOtherContent) {
        CISOtherContent otherCont = (CISOtherContent)payload;
        if (otherCont.getMimeType().equalsIgnoreCase(CoreConstants.MIME_TYPE_KMZ)) {
            AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_KMZ).msgReceived(payload);
        } else if (otherCont.getMimeType().equalsIgnoreCase(CoreConstants.MIME_TYPE_WMS)) {
            AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_WMS).msgReceived(payload);
        } else if (otherCont.getMimeType().equalsIgnoreCase(CoreConstants.MIME_TYPE_WFS)) {
            AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_WFS).msgReceived(payload);
        } if (otherCont.getMimeType().equalsIgnoreCase(CoreConstants.MIME_TYPE_MLP)) {
            AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_MLP).msgReceived(payload);
        }

    } else {
        throw new InvalidObjectException("Object is not OtherContent Object!");
    }


    log.info("messageReceived -->");
}
项目:OpenJSharp    文件:DefaultMXBeanMappingFactory.java   
@Override
final Object fromNonNullOpenValue(Object openValue)
        throws InvalidObjectException {
    final Object[] openArray = (Object[]) openValue;
    final Collection<Object> valueCollection;
    try {
        valueCollection = cast(collectionClass.newInstance());
    } catch (Exception e) {
        throw invalidObjectException("Cannot create collection", e);
    }
    for (Object o : openArray) {
        Object value = elementMapping.fromOpenValue(o);
        if (!valueCollection.add(value)) {
            final String msg =
                "Could not add " + o + " to " +
                collectionClass.getName() +
                " (duplicate set element?)";
            throw new InvalidObjectException(msg);
        }
    }
    return valueCollection;
}
项目:OpenJSharp    文件:DefaultMXBeanMappingFactory.java   
@Override
final Object fromNonNullOpenValue(Object openValue)
        throws InvalidObjectException {
    final Object[] openArray = (Object[]) openValue;
    final Type javaType = getJavaType();
    final Object[] valueArray;
    final Type componentType;
    if (javaType instanceof GenericArrayType) {
        componentType =
            ((GenericArrayType) javaType).getGenericComponentType();
    } else if (javaType instanceof Class<?> &&
               ((Class<?>) javaType).isArray()) {
        componentType = ((Class<?>) javaType).getComponentType();
    } else {
        throw new IllegalArgumentException("Not an array: " +
                                           javaType);
    }
    valueArray = (Object[]) Array.newInstance((Class<?>) componentType,
                                              openArray.length);
    for (int i = 0; i < openArray.length; i++)
        valueArray[i] = elementMapping.fromOpenValue(openArray[i]);
    return valueArray;
}
项目:openjdk-jdk10    文件:IIOPInputStream.java   
private static void setShortField(Object o, Class<?> c, String fieldName, short v)
{
    try {
        Field fld = getDeclaredField( c, fieldName ) ;
        if ((fld != null) && (fld.getType() == Short.TYPE)) {
            long key = bridge.objectFieldOffset( fld ) ;
            bridge.putShort( o, key, v ) ;
        } else {
            throw new InvalidObjectException("Field Type mismatch");
        }
    } catch (Exception e) {
        if (o != null) {
        throw utilWrapper.errorSetShortField( e, fieldName,
            o.toString(),
            new Short(v) ) ;
        } else {
            throw utilWrapper.errorSetShortField( e, fieldName,
                "null " + c.getName() + " object",
                new Short(v) ) ;
        }
    }
}
项目:openjdk-jdk10    文件:DefaultMXBeanMappingFactory.java   
@Override
final Object fromNonNullOpenValue(Object openValue)
        throws InvalidObjectException {
    final Object[] openArray = (Object[]) openValue;
    final Collection<Object> valueCollection;
    try {
        @SuppressWarnings("deprecation")
        Collection<?> tmp = collectionClass.newInstance();
        valueCollection = cast(tmp);
    } catch (Exception e) {
        throw invalidObjectException("Cannot create collection", e);
    }
    for (Object o : openArray) {
        Object value = elementMapping.fromOpenValue(o);
        if (!valueCollection.add(value)) {
            final String msg =
                "Could not add " + o + " to " +
                collectionClass.getName() +
                " (duplicate set element?)";
            throw new InvalidObjectException(msg);
        }
    }
    return valueCollection;
}
项目:openjdk-jdk10    文件:IIOPInputStream.java   
private static void setByteField(Object o, Class<?> c, String fieldName, byte v)
{
    try {
        Field fld = getDeclaredField( c, fieldName ) ;
        if ((fld != null) && (fld.getType() == Byte.TYPE)) {
            long key = bridge.objectFieldOffset( fld ) ;
            bridge.putByte( o, key, v ) ;
        } else {
            throw new InvalidObjectException("Field Type mismatch");
        }
    } catch (Exception e) {
        if (o != null) {
            throw utilWrapper.errorSetByteField( e, fieldName,
                o.toString(),
                new Byte(v) ) ;
        } else {
            throw utilWrapper.errorSetByteField( e, fieldName,
                "null " + c.getName() + " object",
                new Byte(v) ) ;
        }
    }
}
项目:OpenJSharp    文件:GcInfoCompositeData.java   
public static Map<String, MemoryUsage>
        getMemoryUsageAfterGc(CompositeData cd) {
    try {
        TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC);
        //return (Map<String,MemoryUsage>)
        return cast(memoryUsageMapType.toJavaTypeData(td));
    } catch (InvalidObjectException | OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
项目:jdk8u-jdk    文件:MappedMXBeanType.java   
Object toJavaTypeData(Object data)
    throws OpenDataException, InvalidObjectException {

    final Object[] openArray = (Object[]) data;
    List<Object> result = new ArrayList<>(openArray.length);
    for (Object o : openArray) {
        result.add(paramType.toJavaTypeData(o));
    }
    return result;
}
项目:OpenJSharp    文件:ChoiceFormat.java   
/**
 * After reading an object from the input stream, do a simple verification
 * to maintain class invariants.
 * @throws InvalidObjectException if the objects read from the stream is invalid.
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    if (choiceLimits.length != choiceFormats.length) {
        throw new InvalidObjectException(
                "limits and format arrays of different length.");
    }
}
项目:jdk8u-jdk    文件:DirectoryIteratorException.java   
/**
 * Called to read the object from a stream.
 *
 * @throws  InvalidObjectException
 *          if the object is invalid or has a cause that is not
 *          an {@code IOException}
 */
private void readObject(ObjectInputStream s)
    throws IOException, ClassNotFoundException
{
    s.defaultReadObject();
    Throwable cause = super.getCause();
    if (!(cause instanceof IOException))
        throw new InvalidObjectException("Cause must be an IOException");
}
项目:incubator-netbeans    文件:VariableMirrorTranslator.java   
private static void setValueToFinalField(ObjectReference obj, String name, ClassType clazz, Value fv, VirtualMachine vm, ThreadReference thread) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ClassNotPreparedExceptionWrapper, ClassNotLoadedException, ObjectCollectedExceptionWrapper, IncompatibleThreadStateException, UnsupportedOperationExceptionWrapper, InvalidTypeException, InvalidObjectException {
    ObjectReference fieldRef = getDeclaredOrInheritedField(clazz, name, vm, thread);
    if (fieldRef == null) {
        InvalidObjectException ioex = new InvalidObjectException("No field "+name+" of class "+clazz);
        throw ioex;
    }
    // field.setAccessible(true);
    ClassType fieldClassType = (ClassType) ValueWrapper.type(fieldRef);
    com.sun.jdi.Method setAccessibleMethod = ClassTypeWrapper.concreteMethodByName(
            fieldClassType, "setAccessible", "(Z)V");
    try {
        ObjectReferenceWrapper.invokeMethod(fieldRef, thread, setAccessibleMethod,
                                            Collections.singletonList(vm.mirrorOf(true)),
                                            ClassType.INVOKE_SINGLE_THREADED);
        // field.set(newInstance, fv);
        com.sun.jdi.Method setMethod = ClassTypeWrapper.concreteMethodByName(
                fieldClassType, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V");
        if (fv instanceof PrimitiveValue) {
            PrimitiveType pt = (PrimitiveType) ValueWrapper.type(fv);
            ReferenceType fieldBoxingClass = EvaluatorVisitor.adjustBoxingType(clazz, pt, null);
            fv = EvaluatorVisitor.box((PrimitiveValue) fv, fieldBoxingClass, thread, null);
        }
        List<Value> args = Arrays.asList(new Value[] { obj, fv });
        ObjectReferenceWrapper.invokeMethod(fieldRef, thread, setMethod,
                                            args,
                                            ClassType.INVOKE_SINGLE_THREADED);
    } catch (InvocationException iex) {
        throw new InvalidObjectException(
                "Problem setting value "+fv+" to field "+name+" of class "+clazz+
                " : "+iex.exception());
    }
}
项目:jdk8u-jdk    文件:ValueRange.java   
/**
 * Restore the state of an ValueRange from the stream.
 * Check that the values are valid.
 *
 * @param s the stream to read
 * @throws InvalidObjectException if
 *     the smallest minimum is greater than the smallest maximum,
 *  or the smallest maximum is greater than the largest maximum
 *  or the largest minimum is greater than the largest maximum
 * @throws ClassNotFoundException if a class cannot be resolved
 */
private void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException, InvalidObjectException
{
    s.defaultReadObject();
    if (minSmallest > minLargest) {
        throw new InvalidObjectException("Smallest minimum value must be less than largest minimum value");
    }
    if (maxSmallest > maxLargest) {
        throw new InvalidObjectException("Smallest maximum value must be less than largest maximum value");
    }
    if (minLargest > maxLargest) {
        throw new InvalidObjectException("Minimum value must be less than maximum value");
    }
}
项目:openjdk-jdk10    文件:MappedMXBeanType.java   
public static Object toJavaTypeData(Object openData, Type t)
        throws OpenDataException, InvalidObjectException {
    if (openData == null) {
        return null;
    }
    MappedMXBeanType mt = getMappedType(t);
    return mt.toJavaTypeData(openData);
}
项目:CommonInformationSpace    文件:CapConnectorCoreExt.java   
/**
 * This message is called by the ConnectorCore when a message was received. It will be translatet to the Application
 * representation and the translatet message if send via the registered callback to the application.
 * @param msg
 * @throws InvalidObjectException
 */
public void msgReceived(CISPayload payload) throws InvalidObjectException {
    log.info("--> messageReceived");

    //Parse your object to your domain objects here

    // create and forward the message to the connector
    AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_CAP).msgReceived(payload);
}
项目:jdk8u-jdk    文件:EnumSyntax.java   
/**
 * During object input, convert this deserialized enumeration instance to
 * the proper enumeration value defined in the enumeration attribute class.
 *
 * @return  The enumeration singleton value stored at index
 *          <I>i</I>-<I>L</I> in the enumeration value table returned by
 *          {@link #getEnumValueTable() getEnumValueTable()},
 *          where <I>i</I> is this enumeration value's integer value and
 *          <I>L</I> is the value returned by {@link #getOffset()
 *          getOffset()}.
 *
 * @throws ObjectStreamException if the stream can't be deserialised
 * @throws  InvalidObjectException
 *     Thrown if the enumeration value table is null, this enumeration
 *     value's integer value does not correspond to an element in the
 *     enumeration value table, or the corresponding element in the
 *     enumeration value table is null. (Note: {@link
 *     java.io.InvalidObjectException InvalidObjectException} is a subclass
 *     of {@link java.io.ObjectStreamException ObjectStreamException}, which
 *     <CODE>readResolve()</CODE> is declared to throw.)
 */
protected Object readResolve() throws ObjectStreamException {

    EnumSyntax[] theTable = getEnumValueTable();

    if (theTable == null) {
        throw new InvalidObjectException(
                            "Null enumeration value table for class " +
                            getClass());
    }

    int theOffset = getOffset();
    int theIndex = value - theOffset;

    if (0 > theIndex || theIndex >= theTable.length) {
        throw new InvalidObjectException
            ("Integer value = " +  value + " not in valid range " +
             theOffset + ".." + (theOffset + theTable.length - 1) +
             "for class " + getClass());
    }

    EnumSyntax result = theTable[theIndex];
    if (result == null) {
        throw new InvalidObjectException
            ("No enumeration value for integer value = " +
             value + "for class " + getClass());
    }
    return result;
}
项目:CommonInformationSpace    文件:Validator.java   
/**
 * This method validates if the given Object is a valid Google CAP Object.
 *  
 * @param msg The Coogle CAP Object
 * @return the valid Google CAP Object
 * @throws InvalidObjectException If the Object is no valid Google CAP object
 */
public static Alert checkIfAlertObject(Object msg) throws InvalidObjectException {
    Alert alert = null;
    if (msg instanceof Alert) {
        alert = (Alert)msg;
    } else {
        throw new InvalidObjectException("Given Object is no Alert Object!");
    }
    return alert;
}
项目:OpenJSharp    文件:MBeanTrustPermission.java   
private void readObject(ObjectInputStream in)
     throws IOException, ClassNotFoundException {

    // Reading private fields of base class
    in.defaultReadObject();
    try {
        validate(super.getName(),super.getActions());
    } catch (IllegalArgumentException e) {
        throw new InvalidObjectException(e.getMessage());
    }
}
项目:openjdk-jdk10    文件:WeekFields.java   
/**
 * Restore the state of a WeekFields from the stream.
 * Check that the values are valid.
 *
 * @param s the stream to read
 * @throws InvalidObjectException if the serialized object has an invalid
 *     value for firstDayOfWeek or minimalDays.
 * @throws ClassNotFoundException if a class cannot be resolved
 */
private void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException, InvalidObjectException
{
    s.defaultReadObject();
    if (firstDayOfWeek == null) {
        throw new InvalidObjectException("firstDayOfWeek is null");
    }

    if (minimalDays < 1 || minimalDays > 7) {
        throw new InvalidObjectException("Minimal number of days is invalid");
    }
}
项目:openjdk-jdk10    文件:TargetedNotification.java   
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    ois.defaultReadObject();
    try {
        validate(this.notif, this.id);
    } catch (IllegalArgumentException e) {
        throw new InvalidObjectException(e.getMessage());
    }
}
项目:openjdk-jdk10    文件:WeekFields.java   
/**
 * Return the singleton WeekFields associated with the
 * {@code firstDayOfWeek} and {@code minimalDays}.
 * @return the singleton WeekFields for the firstDayOfWeek and minimalDays.
 * @throws InvalidObjectException if the serialized object has invalid
 *     values for firstDayOfWeek or minimalDays.
 */
private Object readResolve() throws InvalidObjectException {
    try {
        return WeekFields.of(firstDayOfWeek, minimalDays);
    } catch (IllegalArgumentException iae) {
        throw new InvalidObjectException("Invalid serialized WeekFields: " + iae.getMessage());
    }
}
项目:guava-mock    文件:ImmutableListMultimap.java   
@GwtIncompatible // java.io.ObjectInputStream
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);
    }

    ImmutableList.Builder<Object> valuesBuilder = ImmutableList.builder();
    for (int j = 0; j < valueCount; j++) {
      valuesBuilder.add(stream.readObject());
    }
    builder.put(key, valuesBuilder.build());
    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);
}
项目:jdk8u-jdk    文件:TextAttribute.java   
/**
 * Resolves instances being deserialized to the predefined constants.
 */
protected Object readResolve() throws InvalidObjectException {
    if (this.getClass() != TextAttribute.class) {
        throw new InvalidObjectException(
            "subclass didn't correctly implement readResolve");
    }

    TextAttribute instance = instanceMap.get(getName());
    if (instance != null) {
        return instance;
    } else {
        throw new InvalidObjectException("unknown attribute name");
    }
}
项目:openjdk-jdk10    文件:JComponent.java   
/**
 * This is the method that's called after the entire graph
 * of objects has been read in.  It initializes
 * the UI property of all of the copmonents with
 * <code>SwingUtilities.updateComponentTreeUI</code>.
 */
public void validateObject() throws InvalidObjectException {
    try {
        for (JComponent root : roots) {
            SwingUtilities.updateComponentTreeUI(root);
        }
    }
    finally {
        readObjectCallbacks.remove(inputStream);
    }
}
项目:googles-monorepo-demo    文件:ImmutableListMultimap.java   
@GwtIncompatible // java.io.ObjectInputStream
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);
    }

    ImmutableList.Builder<Object> valuesBuilder = ImmutableList.builder();
    for (int j = 0; j < valueCount; j++) {
      valuesBuilder.add(stream.readObject());
    }
    builder.put(key, valuesBuilder.build());
    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);
}
项目:fitnotifications    文件:MessageFormat.java   
/**
 * Resolves instances being deserialized to the predefined constants.
 *
 * @return resolved MessageFormat.Field constant
 * @throws InvalidObjectException if the constant could not be resolved.
 *
 * @stable ICU 3.8
 */
@Override
protected Object readResolve() throws InvalidObjectException {
    if (this.getClass() != MessageFormat.Field.class) {
        throw new InvalidObjectException(
            "A subclass of MessageFormat.Field must implement readResolve.");
    }
    if (this.getName().equals(ARGUMENT.getName())) {
        return ARGUMENT;
    } else {
        throw new InvalidObjectException("Unknown attribute name.");
    }
}
项目:BetterRandom    文件:BaseRandom.java   
/**
 * Used to deserialize a subclass instance that wasn't a subclass instance when it was serialized.
 * Since that means we can't deserialize our seed, we generate a new one with the {@link
 * DefaultSeedGenerator}.
 * @throws InvalidObjectException if the {@link DefaultSeedGenerator} fails.
 */
@SuppressWarnings("OverriddenMethodCallDuringObjectConstruction") private void readObjectNoData()
    throws InvalidObjectException {
  LOG.warn("BaseRandom.readObjectNoData() invoked; using DefaultSeedGenerator");
  try {
    fallbackSetSeed();
  } catch (final RuntimeException e) {
    throw (InvalidObjectException) (new InvalidObjectException(
        "Failed to deserialize or generate a seed").initCause(e.getCause()));
  }
  initTransientFields();
  setSeedInternal(seed);
}
项目:jdk8u-jdk    文件:AttributedCharacterIterator.java   
/**
 * Resolves instances being deserialized to the predefined constants.
 *
 * @return the resolved {@code Attribute} object
 * @throws InvalidObjectException if the object to resolve is not
 *                                an instance of {@code Attribute}
 */
protected Object readResolve() throws InvalidObjectException {
    if (this.getClass() != Attribute.class) {
        throw new InvalidObjectException("subclass didn't correctly implement readResolve");
    }

    Attribute instance = instanceMap.get(getName());
    if (instance != null) {
        return instance;
    } else {
        throw new InvalidObjectException("unknown attribute name");
    }
}
项目:CommonInformationSpace    文件:MLPConnectorCoreExt.java   
/**
 * This method receives an Object (MLP as String) and forwards it to the CIS CIS Core
 * 
 * @param msg the MLP String
 * @throws InvalidObjectException when the String is not valid MLP
 */
public void notify(Object msg, Map<DEParameters, String> deParameters, boolean dontEnvelope) throws InvalidObjectException {
    log.info("--> notify");

    String msgStr = null;
    if (msg instanceof String) {
        msgStr = (String)msg;
        if (msgStr.startsWith("<?xml version")) {
            int idx = msgStr.indexOf("<svc_");
            if (idx != -1) {
                msgStr = msgStr.substring(idx);
            }
        }
    } else {
        throw new InvalidObjectException("Given Object is no valid MLP Message!");
    }

    try {
        CISXMLContent xmlCont = new CISXMLContent();
        xmlCont.setEmbeddedXMLContent(msgStr);
        restSender.notify(CoreConstants.MSGTYPE_MLP, xmlCont, null, false);
    } catch (CISCommunicationException | CISInvalidXMLObject e) {
        log.error("notify: " + e);
    }

    log.info("notify -->");
}
项目:OpenJSharp    文件:NumberFormat.java   
/**
 * Resolves instances being deserialized to the predefined constants.
 *
 * @throws InvalidObjectException if the constant could not be resolved.
 * @return resolved NumberFormat.Field constant
 */
@Override
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");
    }
}
项目:OpenJSharp    文件:WeekFields.java   
/**
 * Return the singleton WeekFields associated with the
 * {@code firstDayOfWeek} and {@code minimalDays}.
 * @return the singleton WeekFields for the firstDayOfWeek and minimalDays.
 * @throws InvalidObjectException if the serialized object has invalid
 *     values for firstDayOfWeek or minimalDays.
 */
private Object readResolve() throws InvalidObjectException {
    try {
        return WeekFields.of(firstDayOfWeek, minimalDays);
    } catch (IllegalArgumentException iae) {
        throw new InvalidObjectException("Invalid serialized WeekFields: " + iae.getMessage());
    }
}
项目:CommonInformationSpace    文件:MLPConnectorCoreExt.java   
/**
 * This message is called by the ConnectorCore when a message was receive. It will be translatet to the Application
 * representation and the translatet message if send via the registered callback to the application.
 * 
 * @param msg
 * @throws InvalidObjectException
 */
public void msgReceived(CISPayload payload) throws InvalidObjectException {
    log.info("--> messageReceived");

    // create and forward the message to the connector
    if (AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_MLP) != null) {
        AppCallbackHandlerImpl.getInstance().getCallback(CoreConstants.MSGTYPE_MLP).msgReceived(payload);
    }

    log.info("messageReceived -->");
}
项目:FlickLauncher    文件:RestoreDbTask.java   
/**
 * Returns the profile id used in the favorites table of the provided db.
 */
protected long getDefaultProfileId(SQLiteDatabase db) throws Exception {
    try (Cursor c = db.rawQuery("PRAGMA table_info (favorites)", null)){
        int nameIndex = c.getColumnIndex(INFO_COLUMN_NAME);
        while (c.moveToNext()) {
            if (Favorites.PROFILE_ID.equals(c.getString(nameIndex))) {
                return c.getLong(c.getColumnIndex(INFO_COLUMN_DEFAULT_VALUE));
            }
        }
        throw new InvalidObjectException("Table does not have a profile id column");
    }
}
项目:jdk8u-jdk    文件:DefaultMXBeanMappingFactory.java   
final Object fromCompositeData(CompositeData cd,
                               String[] itemNames,
                               MXBeanMapping[] converters)
        throws InvalidObjectException {
    try {
        return MethodUtil.invoke(fromMethod, null, new Object[] {cd});
    } catch (Exception e) {
        final String msg = "Failed to invoke from(CompositeData)";
        throw invalidObjectException(msg, e);
    }
}