Java 类java.io.ObjectStreamException 实例源码

项目:openjdk-jdk10    文件:URL.java   
/**
  * Replaces the de-serialized object with an URL object.
  *
  * @return a newly created object from deserialized data
  *
  * @throws ObjectStreamException if a new object replacing this
  * object could not be created
  */

private Object readResolve() throws ObjectStreamException {

     URLStreamHandler handler = null;
     // already been checked in readObject
     handler = getURLStreamHandler(tempState.getProtocol());

     URL replacementURL = null;
     if (isBuiltinStreamHandler(handler.getClass().getName())) {
         replacementURL = fabricateNewURL();
     } else {
         replacementURL = setDeserializedFields(handler);
     }
     return replacementURL;
 }
项目:fitnotifications    文件:TimeUnit.java   
private Object readResolve() throws ObjectStreamException {
    // The old index field used to uniquely identify the time unit.
    switch (index) {
    case 6:
        return SECOND;
    case 5:
        return MINUTE;
    case 4:
        return HOUR;
    case 3:
        return DAY;
    case 2:
        return WEEK;
    case 1:
        return MONTH;
    case 0:
        return YEAR;
    default:
        throw new InvalidObjectException("Bad index: " + index);
    }
}
项目:openjdk-jdk10    文件:Inet4Address.java   
/**
 * Replaces the object to be serialized with an InetAddress object.
 *
 * @return the alternate object to be serialized.
 *
 * @throws ObjectStreamException if a new object replacing this
 * object could not be created
 */
private Object writeReplace() throws ObjectStreamException {
    // will replace the to be serialized 'this' object
    InetAddress inet = new InetAddress();
    inet.holder().hostName = holder().getHostName();
    inet.holder().address = holder().getAddress();

    /**
     * Prior to 1.4 an InetAddress was created with a family
     * based on the platform AF_INET value (usually 2).
     * For compatibility reasons we must therefore write the
     * the InetAddress with this family.
     */
    inet.holder().family = 2;

    return inet;
}
项目:parabuild-ci    文件:AxisLocation.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(AxisLocation.TOP_OR_RIGHT)) {
        return AxisLocation.TOP_OR_RIGHT;
    }
    else if (this.equals(AxisLocation.BOTTOM_OR_RIGHT)) {
        return AxisLocation.BOTTOM_OR_RIGHT;
    }    
    else if (this.equals(AxisLocation.TOP_OR_LEFT)) {
        return AxisLocation.TOP_OR_LEFT;
    }    
    else if (this.equals(AxisLocation.BOTTOM_OR_LEFT)) {
        return AxisLocation.BOTTOM_OR_LEFT;
    }
    return null;
}
项目:OpenJSharp    文件:Inet4Address.java   
/**
 * Replaces the object to be serialized with an InetAddress object.
 *
 * @return the alternate object to be serialized.
 *
 * @throws ObjectStreamException if a new object replacing this
 * object could not be created
 */
private Object writeReplace() throws ObjectStreamException {
    // will replace the to be serialized 'this' object
    InetAddress inet = new InetAddress();
    inet.holder().hostName = holder().getHostName();
    inet.holder().address = holder().getAddress();

    /**
     * Prior to 1.4 an InetAddress was created with a family
     * based on the platform AF_INET value (usually 2).
     * For compatibility reasons we must therefore write the
     * the InetAddress with this family.
     */
    inet.holder().family = 2;

    return inet;
}
项目:parabuild-ci    文件:DatasetRenderingOrder.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(DatasetRenderingOrder.FORWARD)) {
        return DatasetRenderingOrder.FORWARD;
    }
    else if (this.equals(DatasetRenderingOrder.REVERSE)) {
        return DatasetRenderingOrder.REVERSE;
    }      
    return null;
}
项目:JOpt    文件:MIPInfeasibleException.java   
/** Make serialization work. **/
private Object readResolve () throws ObjectStreamException
   {
       switch(type) {
        case 1:
            return LOWER;
        case 2:
            return UPPER;
       }
       throw new InvalidObjectException("Unknown type: " + type);
   }
项目:incubator-netbeans    文件:SourcesView.java   
public Object readResolve() throws ObjectStreamException {
    try {
        Class c = Lookup.getDefault().lookup(ClassLoader.class).loadClass("org.netbeans.modules.debugger.ui.views.View"); // NOI18N
        Method m = c.getDeclaredMethod("getSourcesView", new Class[] {}); // NOI18N
        Object tc = m.invoke(null, new Object[] {});
        return tc;
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
        return null;
    }
}
项目:parabuild-ci    文件:LengthConstraintType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(LengthConstraintType.NONE)) {
        return LengthConstraintType.NONE;
    }
    else if (this.equals(LengthConstraintType.RANGE)) {
        return LengthConstraintType.RANGE;
    }
    else if (this.equals(LengthConstraintType.FIXED)) {
        return LengthConstraintType.FIXED;
    }
    return null;
}
项目:Krine    文件:Primitive.java   
private Object readResolve() throws ObjectStreamException {
    if (value == Special.NULL_VALUE) {
        return Primitive.NULL;
    } else if (value == Special.VOID_TYPE) {
        return Primitive.VOID;
    } else {
        return this;
    }
}
项目:parabuild-ci    文件:AreaRendererEndType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    Object result = null;
    if (this.equals(AreaRendererEndType.LEVEL)) {
        result = AreaRendererEndType.LEVEL;
    }
    else if (this.equals(AreaRendererEndType.TAPER)) {
        result = AreaRendererEndType.TAPER;
    }
    else if (this.equals(AreaRendererEndType.TRUNCATE)) {
        result = AreaRendererEndType.TRUNCATE;
    }
    return result;
}
项目:parabuild-ci    文件:DialShape.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(DialShape.CIRCLE)) {
        return DialShape.CIRCLE;
    }
    else if (this.equals(DialShape.CHORD)) {
        return DialShape.CHORD;
    }      
    else if (this.equals(DialShape.PIE)) {
        return DialShape.PIE;
    }      
    return null;
}
项目:incubator-netbeans    文件:NbSheet.java   
/** Resolve to singleton instance, if needed. */
public Object readResolve ()
throws ObjectStreamException {
    if (global) {
        return getDefault();
    } else {
        if ((nodes == null) || (nodes.length <= 0)) {
            return null;
        }
    }
    return this;
}
项目:parabuild-ci    文件:CategoryAnchor.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(CategoryAnchor.START)) {
        return CategoryAnchor.START;
    }
    else if (this.equals(CategoryAnchor.MIDDLE)) {
        return CategoryAnchor.MIDDLE;
    }    
    else if (this.equals(CategoryAnchor.END)) {
        return CategoryAnchor.END;
    }    
    return null;
}
项目:Pogamut3    文件:VisibilityMatrix.java   
private Object readResolve() throws ObjectStreamException {
    mutex = new Object();
    coverPoints = new HashMap<Integer, Set<VisibilityLocation>>();
    visiblePoints = new HashMap<Integer, Set<VisibilityLocation>>();
    coverNavPoints = new HashMap<Integer, Set<NavPoint>>();
    visibleNavPoints = new HashMap<Integer, Set<NavPoint>>();

    return this;
}
项目:parabuild-ci    文件:HistogramType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return the object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(HistogramType.FREQUENCY)) {
        return HistogramType.FREQUENCY;
    }
    else if (this.equals(HistogramType.RELATIVE_FREQUENCY)) {
        return HistogramType.RELATIVE_FREQUENCY;
    }
    else if (this.equals(HistogramType.SCALE_AREA_TO_1)) {
        return HistogramType.SCALE_AREA_TO_1;
    }
    return null;
}
项目:parabuild-ci    文件:ChartChangeEventType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(ChartChangeEventType.GENERAL)) {
        return ChartChangeEventType.GENERAL;
    }
    else if (this.equals(ChartChangeEventType.NEW_DATASET)) {
        return ChartChangeEventType.NEW_DATASET;
    }
    else if (this.equals(ChartChangeEventType.DATASET_UPDATED)) {
        return ChartChangeEventType.DATASET_UPDATED;
    }
    return null;
}
项目:parabuild-ci    文件:AreaRendererEndType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    Object result = null;
    if (this.equals(AreaRendererEndType.LEVEL)) {
        result = AreaRendererEndType.LEVEL;
    }
    else if (this.equals(AreaRendererEndType.TAPER)) {
        result = AreaRendererEndType.TAPER;
    }
    else if (this.equals(AreaRendererEndType.TRUNCATE)) {
        result = AreaRendererEndType.TRUNCATE;
    }
    return result;
}
项目:parabuild-ci    文件:DomainOrder.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(DomainOrder.ASCENDING)) {
        return DomainOrder.ASCENDING;
    }
    else if (this.equals(DomainOrder.DESCENDING)) {
        return DomainOrder.DESCENDING;
    }
    else if (this.equals(DomainOrder.NONE)) {
        return DomainOrder.NONE;
    }
    return null;
}
项目:parabuild-ci    文件:SeriesRenderingOrder.java   
/**
 * Ensures that serialization returns the unique instances.
 *
 * @return The object.
 *
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(SeriesRenderingOrder.FORWARD)) {
        return SeriesRenderingOrder.FORWARD;
    }
    else if (this.equals(SeriesRenderingOrder.REVERSE)) {
        return SeriesRenderingOrder.REVERSE;
    }
    return null;
}
项目:lams    文件:DefaultListableBeanFactory.java   
protected Object writeReplace() throws ObjectStreamException {
    if (this.serializationId != null) {
        return new SerializedBeanFactoryReference(this.serializationId);
    }
    else {
        throw new NotSerializableException("DefaultListableBeanFactory has no serialization id");
    }
}
项目:parabuild-ci    文件:XYCoordinateType.java   
/**
 * Ensures that serialization returns the unique instances.
 *
 * @return The object.
 *
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(XYCoordinateType.DATA)) {
        return XYCoordinateType.DATA;
    }
    else if (this.equals(XYCoordinateType.RELATIVE)) {
        return XYCoordinateType.RELATIVE;
    }     
    else if (this.equals(XYCoordinateType.INDEX)) {
        return XYCoordinateType.INDEX;
    }     
    return null;
}
项目:Elasticsearch    文件:Message.java   
/**
 * When serialized, we eagerly convert sources to strings. This hurts our formatting, but it
 * guarantees that the receiving end will be able to read the message.
 */
private Object writeReplace() throws ObjectStreamException {
    Object[] sourcesAsStrings = sources.toArray();
    for (int i = 0; i < sourcesAsStrings.length; i++) {
        sourcesAsStrings[i] = Errors.convert(sourcesAsStrings[i]).toString();
    }
    return new Message(Arrays.asList(sourcesAsStrings), message, cause);
}
项目:OpenJSharp    文件:CertPath.java   
/**
 * Replaces the {@code CertPath} to be serialized with a
 * {@code CertPathRep} object.
 *
 * @return the {@code CertPathRep} to be serialized
 *
 * @throws ObjectStreamException if a {@code CertPathRep} object
 * representing this certification path could not be created
 */
protected Object writeReplace() throws ObjectStreamException {
    try {
        return new CertPathRep(type, getEncoded());
    } catch (CertificateException ce) {
        NotSerializableException nse =
            new NotSerializableException
                ("java.security.cert.CertPath: " + type);
        nse.initCause(ce);
        throw nse;
    }
}
项目:OpenJSharp    文件: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;
}
项目:parabuild-ci    文件:DatasetRenderingOrder.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(DatasetRenderingOrder.FORWARD)) {
        return DatasetRenderingOrder.FORWARD;
    }
    else if (this.equals(DatasetRenderingOrder.REVERSE)) {
        return DatasetRenderingOrder.REVERSE;
    }      
    return null;
}
项目:parabuild-ci    文件:CategoryLabelWidthType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(CategoryLabelWidthType.CATEGORY)) {
        return CategoryLabelWidthType.CATEGORY;
    }
    else if (this.equals(CategoryLabelWidthType.RANGE)) {
        return CategoryLabelWidthType.RANGE;
    }    
    return null;
}
项目:openjdk-jdk10    文件:ImmutableCollections.java   
/**
 * Creates and returns an immutable collection from this proxy class.
 * The instance returned is created as if by calling one of the
 * static factory methods for
 * <a href="List.html#immutable">List</a>,
 * <a href="Map.html#immutable">Map</a>, or
 * <a href="Set.html#immutable">Set</a>.
 * This proxy class is the serial form for all immutable collection instances,
 * regardless of implementation type. This is necessary to ensure that the
 * existence of any particular implementation type is kept out of the
 * serialized form.
 *
 * @return a collection created from this proxy object
 * @throws InvalidObjectException if the tag value is illegal or if an exception
 *         is thrown during creation of the collection
 * @throws ObjectStreamException if another serialization error has occurred
 * @since 9
 */
private Object readResolve() throws ObjectStreamException {
    try {
        if (array == null) {
            throw new InvalidObjectException("null array");
        }

        // use low order 8 bits to indicate "kind"
        // ignore high order 24 bits
        switch (tag & 0xff) {
            case IMM_LIST:
                return List.of(array);
            case IMM_SET:
                return Set.of(array);
            case IMM_MAP:
                if (array.length == 0) {
                    return ImmutableCollections.Map0.instance();
                } else if (array.length == 2) {
                    return new ImmutableCollections.Map1<>(array[0], array[1]);
                } else {
                    return new ImmutableCollections.MapN<>(array);
                }
            default:
                throw new InvalidObjectException(String.format("invalid flags 0x%x", tag));
        }
    } catch (NullPointerException|IllegalArgumentException ex) {
        InvalidObjectException ioe = new InvalidObjectException("invalid object");
        ioe.initCause(ex);
        throw ioe;
    }
}
项目:parabuild-ci    文件:HistogramType.java   
/**
 * Ensures that serialization returns the unique instances.
 * 
 * @return The object.
 * 
 * @throws ObjectStreamException if there is a problem.
 */
private Object readResolve() throws ObjectStreamException {
    if (this.equals(HistogramType.FREQUENCY)) {
        return HistogramType.FREQUENCY;
    }
    else if (this.equals(HistogramType.RELATIVE_FREQUENCY)) {
        return HistogramType.RELATIVE_FREQUENCY;
    }
    else if (this.equals(HistogramType.SCALE_AREA_TO_1)) {
        return HistogramType.SCALE_AREA_TO_1;
    }
    return null;
}
项目:jdk8u-jdk    文件:ai.java   
Object readResolve() throws ObjectStreamException {
    return new SealedObjectForKeyProtector(this);
}
项目:incubator-netbeans    文件:SystemFileSystem.java   
private Object writeReplace() throws ObjectStreamException {
    new NotSerializableException("WARNING - SystemFileSystem is not designed to be serialized").printStackTrace(); // NOI18N
    return new SingletonSerializer();
}
项目:incubator-netbeans    文件:FileBasedFileSystem.java   
public Object writeReplace() throws ObjectStreamException {
    return new SerReplace();
}
项目:incubator-netbeans    文件:FileBasedFileSystem.java   
public Object readResolve() throws ObjectStreamException {
    return FileBasedFileSystem.getInstance();
}
项目:monarch    文件:Token.java   
private Object readResolve() throws ObjectStreamException {
  return END_OF_STREAM;
}
项目:incubator-netbeans    文件:ClassName.java   
private Object readResolve() throws ObjectStreamException {
    return getClassName(internalName);
}
项目:incubator-netbeans    文件:ExecutionEnvironmentImpl.java   
Object readResolve() throws ObjectStreamException {
    return ExecutionEnvironmentFactory.fromUniqueID(id);
}
项目:openjdk-jdk10    文件:TransformAttribute.java   
private Object readResolve() throws ObjectStreamException {
    if (transform == null || transform.isIdentity()) {
        return IDENTITY;
    }
    return this;
}
项目:incubator-netbeans    文件:TopComponent.java   
/** Resolve to original top component instance */
private Object readResolve() throws ObjectStreamException {
    return tc;
}
项目:incubator-netbeans    文件:ObsoleteClass.java   
private Object readResolve() throws ObjectStreamException {
    return new FooSetting(prop);
}
项目:incubator-netbeans    文件:Tab.java   
/** Old (3.2) deserialization of the ProjectTab */
public Object readResolve() throws ObjectStreamException {
    getDefault().scheduleValidation();
    return getDefault();
}