當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。