當前位置: 首頁>>代碼示例>>Java>>正文


Java InvalidObjectException.initCause方法代碼示例

本文整理匯總了Java中java.io.InvalidObjectException.initCause方法的典型用法代碼示例。如果您正苦於以下問題:Java InvalidObjectException.initCause方法的具體用法?Java InvalidObjectException.initCause怎麽用?Java InvalidObjectException.initCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.InvalidObjectException的用法示例。


在下文中一共展示了InvalidObjectException.initCause方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例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: toJavaTypeData

import java.io.InvalidObjectException; //導入方法依賴的package包/類
Object toJavaTypeData(Object data)
    throws OpenDataException, InvalidObjectException {

    try {
        return Enum.valueOf(enumClass, (String) data);
    } catch (IllegalArgumentException e) {
        // missing enum constants
        final InvalidObjectException ioe =
            new InvalidObjectException("Enum constant named " +
            (String) data + " is missing");
        ioe.initCause(e);
        throw ioe;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:MappedMXBeanType.java

示例4: readResolve

import java.io.InvalidObjectException; //導入方法依賴的package包/類
/**
 * 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;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:49,代碼來源:ImmutableCollections.java

示例5: toJavaTypeData

import java.io.InvalidObjectException; //導入方法依賴的package包/類
public Object toJavaTypeData(Object data)
    throws OpenDataException, InvalidObjectException {

    try {
        return Enum.valueOf(enumClass, (String) data);
    } catch (IllegalArgumentException e) {
        // missing enum constants
        final InvalidObjectException ioe =
            new InvalidObjectException("Enum constant named " +
            (String) data + " is missing");
        ioe.initCause(e);
        throw ioe;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:MappedMXBeanType.java


注:本文中的java.io.InvalidObjectException.initCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。