当前位置: 首页>>代码示例>>Java>>正文


Java InvalidObjectException类代码示例

本文整理汇总了Java中java.io.InvalidObjectException的典型用法代码示例。如果您正苦于以下问题:Java InvalidObjectException类的具体用法?Java InvalidObjectException怎么用?Java InvalidObjectException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidObjectException类属于java.io包,在下文中一共展示了InvalidObjectException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readObject

import java.io.InvalidObjectException; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:BatchUpdateException.java

示例2: fabricateNewURL

import java.io.InvalidObjectException; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:URL.java

示例3: readObject

import java.io.InvalidObjectException; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:InetSocketAddress.java

示例4: setCharField

import java.io.InvalidObjectException; //导入依赖的package包/类
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) ) ;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:IIOPInputStream.java

示例5: fromNonNullOpenValue

import java.io.InvalidObjectException; //导入依赖的package包/类
@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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:DefaultMXBeanMappingFactory.java

示例6: fabricateNewURL

import java.io.InvalidObjectException; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:URL.java

示例7: msgReceived

import java.io.InvalidObjectException; //导入依赖的package包/类
/**
 * 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 -->");
}
 
开发者ID:DRIVER-EU,项目名称:CommonInformationSpace,代码行数:30,代码来源:OtherContentConnectorCoreExt.java

示例8: fromNonNullOpenValue

import java.io.InvalidObjectException; //导入依赖的package包/类
@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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:DefaultMXBeanMappingFactory.java

示例9: setShortField

import java.io.InvalidObjectException; //导入依赖的package包/类
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) ) ;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:IIOPInputStream.java

示例10: fromNonNullOpenValue

import java.io.InvalidObjectException; //导入依赖的package包/类
@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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DefaultMXBeanMappingFactory.java

示例11: setByteField

import java.io.InvalidObjectException; //导入依赖的package包/类
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) ) ;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:IIOPInputStream.java

示例12: getMemoryUsageAfterGc

import java.io.InvalidObjectException; //导入依赖的package包/类
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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:GcInfoCompositeData.java

示例13: toJavaTypeData

import java.io.InvalidObjectException; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:MappedMXBeanType.java

示例14: readObject

import java.io.InvalidObjectException; //导入依赖的package包/类
/**
 * 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.");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:ChoiceFormat.java

示例15: readObject

import java.io.InvalidObjectException; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:DirectoryIteratorException.java


注:本文中的java.io.InvalidObjectException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。