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


Java InvalidClassException類代碼示例

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


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

示例1: initAppData

import java.io.InvalidClassException; //導入依賴的package包/類
/**
 * 初始化應用數據
 */
private String initAppData() {
    PreferenceHelper.loadDefaults();
    //TODO 測試,待刪除
    if (PreferenceHelper.getSharedPreferences().getBoolean(WeatherSettings.SETTINGS_FIRST_USE.getId(), false)) {
        try {
            PreferenceHelper.savePreference(WeatherSettings.SETTINGS_CURRENT_CITY_ID, "101020100");
            PreferenceHelper.savePreference(WeatherSettings.SETTINGS_FIRST_USE, false);
        } catch (InvalidClassException e) {
            e.printStackTrace();
        }
    }
    Log.d(TAG, "importCityData start");
    CityDBUtil.importCityData();
    Log.d(TAG, "importCityData end");
    return null;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:WelcomeActivity.java

示例2: deleteCity

import java.io.InvalidClassException; //導入依賴的package包/類
@Override
public void deleteCity(String cityId) {

    Observable.just(deleteCityFromDBAndReturnCurrentCityId(cityId))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(currentCityId -> {
                if (currentCityId == null)
                    return;
                try {
                    PreferenceHelper.savePreference(WeatherSettings.SETTINGS_CURRENT_CITY_ID, currentCityId);
                } catch (InvalidClassException e) {
                    e.printStackTrace();
                }
            });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:CityManagerPresenter.java

示例3: deserialize

import java.io.InvalidClassException; //導入依賴的package包/類
/**
 * Deserializes an object from the given <code>InputStream</code>.
 * The deserialization is delegated to an <code>
 * ObjectInputStream</code> instance. 
 * 
 * @param in	The <code>InputStream</code> to deserialize an object
 *				from.
 * 
 * @return The object deserialized from the stream. 
 * @exception IOException is thrown if there was a problem reading
 *		the underlying stream, or an object could not be deserialized
 *		from the stream.
 * 
 * @see java.io.ObjectInputStream
 */
static public Object deserialize(InputStream in)
	throws IOException
{
	if (in==null)
		throw new NullPointerException("in");
	
	ObjectInputStream objIn = new ObjectInputStream(in);
	
	Object obj;
	
	try
	{
		obj = objIn.readObject();
	}
	catch (ClassNotFoundException ex)
	{
		throw new InvalidClassException(ex.toString());
	}
	
	return obj;
}
 
開發者ID:EndlessBot,項目名稱:jLib,代碼行數:37,代碼來源:JavaLayerUtils.java

示例4: convertHttpInvokerAccessException

import java.io.InvalidClassException; //導入依賴的package包/類
/**
 * Convert the given HTTP invoker access exception to an appropriate
 * Spring RemoteAccessException.
 * @param ex the exception to convert
 * @return the RemoteAccessException to throw
 */
protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex) {
	if (ex instanceof ConnectException) {
		return new RemoteConnectFailureException(
				"Could not connect to HTTP invoker remote service at [" + getServiceUrl() + "]", ex);
	}

	if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError ||
			ex instanceof InvalidClassException) {
		return new RemoteAccessException(
				"Could not deserialize result from HTTP invoker remote service [" + getServiceUrl() + "]", ex);
	}

	return new RemoteAccessException(
				"Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:HttpInvokerClientInterceptor.java

示例5: testDefaultOutputWithBadException

import java.io.InvalidClassException; //導入依賴的package包/類
@Test
public void testDefaultOutputWithBadException() throws JoranException, IOException {
    configLogback(LOGBACK_WITH_THREAD);

    String message = "test output with bad exception";

    log.error(message, new InvalidClassException("Class null is invalid"));

    String logger = AbstractLoggingException.class.getCanonicalName();
    String errorClass = InvalidClassException.class.getCanonicalName();
    String message2 = String.format("Bad implementation of '%s' in use", errorClass);

    String output = baos.toString();

    // there must be original log
    assertThat(output).containsPattern(
        DEFAULT_DATE_FORMAT + ERROR + getThreadName() + getLogger() + message + "\n"
    );
    // alongside log about alert level misuse
    assertThat(output).containsPattern(
        DEFAULT_DATE_FORMAT + ERROR + getThreadName() + logger + ":\\d+: \\[P1\\] 0. " + message2 + "\n"
    );
}
 
開發者ID:hmcts,項目名稱:java-logging,代碼行數:24,代碼來源:ReformLoggingLayoutTest.java

示例6: skipCustomUsingFVD

import java.io.InvalidClassException; //導入依賴的package包/類
private void skipCustomUsingFVD(ValueMember[] fields,
                                com.sun.org.omg.SendingContext.CodeBase sender)
                                throws InvalidClassException, StreamCorruptedException,
                                       ClassNotFoundException, IOException
{
    readFormatVersion();
    boolean calledDefaultWriteObject = readBoolean();

    if (calledDefaultWriteObject)
        throwAwayData(fields, sender);

    if (getStreamFormatVersion() == 2) {

        ((ValueInputStream)getOrbStream()).start_value();
        ((ValueInputStream)getOrbStream()).end_value();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:IIOPInputStream.java

示例7: writeInternal

import java.io.InvalidClassException; //導入依賴的package包/類
private static void writeInternal(byte type, Object object, DataOutput out) throws IOException {
    out.writeByte(type);
    switch (type) {
        case ZRULES:
            ((ZoneRules) object).writeExternal(out);
            break;
        case ZOT:
            ((ZoneOffsetTransition) object).writeExternal(out);
            break;
        case ZOTRULE:
            ((ZoneOffsetTransitionRule) object).writeExternal(out);
            break;
        default:
            throw new InvalidClassException("Unknown serialized type");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:Ser.java

示例8: convertStringFromObject

import java.io.InvalidClassException; //導入依賴的package包/類
private static ArrayList<String> convertStringFromObject(Object value) throws InvalidClassException, UnsupportedEncodingException {
    if (value == null) {
        return null;
    }

    ArrayList<String> stringArrayList = new ArrayList<>();
    if (value instanceof ArrayList) {
        for (Object object : (ArrayList<?>)value) {
            ArrayList<String> recursiveList = convertStringFromObject(object);
            if (ValidationUtils.isEmptyList(recursiveList) == false) {
                stringArrayList.addAll(recursiveList);
            }
        }
    } else if (value instanceof ByteBuffer) {
        byte[] stringBytes = ((ByteBuffer)value).array();
        stringArrayList.add(new String(stringBytes, "UTF-8"));
    } else {
        throw new InvalidClassException("value is not array list or string [" + value.getClass() + "]");
    }

    return stringArrayList;
}
 
開發者ID:forusoul70,項目名稱:playTorrent,代碼行數:23,代碼來源:Torrent.java

示例9: deserializeMessage

import java.io.InvalidClassException; //導入依賴的package包/類
/**
 * Deserialize message.
 * @param data bytes
 * @return message
 * @throws IOException if an I/O error occurs when deserializing the message
 */
static Message deserializeMessage(final byte[] data) throws IOException {
    final ByteArrayInputStream byteInput = new ByteArrayInputStream(data);
    final ObjectInputStream objectInput = new ObjectInputStream(byteInput);

    try {
        return (Message) objectInput.readObject();
    } catch (final ClassCastException | ClassNotFoundException e) {
        final InvalidClassException ice = new InvalidClassException(
                "Could not deserialize object from received data");
        ice.initCause(e);
        throw ice;
    } finally {
        IOUtils.closeSilently(byteInput);
        IOUtils.closeSilently(objectInput);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:23,代碼來源:StreamUtils.java

示例10: testGlobalPattern

import java.io.InvalidClassException; //導入依賴的package包/類
/**
     * Serialize and deserialize an object using the default process-wide filter
     * and check allowed or reject.
     *
     * @param pattern the pattern
     * @param object the test object
     * @param allowed the expected result from ObjectInputStream (exception or not)
     */
    static void testGlobalPattern(String pattern, Object object, boolean allowed) {
        try {
//            System.out.printf("global %s pattern: %s, obj: %s%n", (allowed ? "allowed" : "not allowed"), pattern, object);
            byte[] bytes = SerialFilterTest.writeObjects(object);
            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                 ObjectInputStream ois = new ObjectInputStream(bais)) {
                Object o = ois.readObject();
            } catch (EOFException eof) {
                // normal completion
            } catch (ClassNotFoundException cnf) {
                Assert.fail("Deserializing", cnf);
            }
            Assert.assertTrue(allowed, "filter should have thrown an exception");
        } catch (IllegalArgumentException iae) {
            Assert.fail("bad format pattern", iae);
        } catch (InvalidClassException ice) {
            Assert.assertFalse(allowed, "filter should not have thrown an exception: " + ice);
        } catch (IOException ioe) {
            Assert.fail("Unexpected IOException", ioe);
        }
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:30,代碼來源:GlobalFilterTest.java

示例11: UnicastServerRef

import java.io.InvalidClassException; //導入依賴的package包/類
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:FilterUSRTest.java

示例12: invokeObjectReader

import java.io.InvalidClassException; //導入依賴的package包/類
private boolean invokeObjectReader(ObjectStreamClass osc, Object obj, Class aclass)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IOException
{
    try {
        return osc.invokeReadObject( obj, this ) ;
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        if (t instanceof ClassNotFoundException)
            throw (ClassNotFoundException)t;
        else if (t instanceof IOException)
            throw (IOException)t;
        else if (t instanceof RuntimeException)
            throw (RuntimeException) t;
        else if (t instanceof Error)
            throw (Error) t;
        else
            // XXX I18N, logging needed.
            throw new Error("internal error");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:IIOPInputStream.java

示例13: testReadWrite

import java.io.InvalidClassException; //導入依賴的package包/類
public static void testReadWrite() {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        testWrite(oos);
        oos.flush();
        oos.close();
        byte buf[] = baos.toByteArray();
        ByteArrayInputStream bais = new ByteArrayInputStream(buf);
        ObjectInputStream ois = new ObjectInputStream(bais);
        testRead(ois, true);
    } catch (InvalidClassException ice) {
        throw new RuntimeException("Object read failed from loopback");
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException("IOException testing loopback");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:TestSerialization.java

示例14: main

import java.io.InvalidClassException; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    setup();

    try (URLClassLoader ldr =
        new URLClassLoader(new URL[]{ new URL("file:foo.jar") },
                PackageAccessTest.class.getClassLoader())) {
        bcl = Class.forName("B", true, ldr);
        dcl = Class.forName("D", true, ldr);

        Object b = bcl.newInstance();
        try {
            swizzle(b);
            throw new Error("expected InvalidClassException for class B");
        } catch (InvalidClassException e) {
            System.out.println("caught " + e);
            e.printStackTrace();
        }
        if (A.packagePrivateConstructorInvoked) {
            throw new Error("package private constructor of A invoked");
        }

        Object d = dcl.newInstance();
        swizzle(d);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:PackageAccessTest.java

示例15: main

import java.io.InvalidClassException; //導入依賴的package包/類
public static void main(String[] args) {
    SingleLinkClusterer s = new SingleLinkClusterer();
    SimilarityComparatorListener c = new SimilarityComparatorListener() {
        public ISimilarity getSimilarityBetween(Object oFirst, Object oSecond) throws InvalidClassException {
            ISimilarity res = new SimpleSimilarity(
                    org.apache.commons.lang.StringUtils.getLevenshteinDistance(
                    (String)oFirst, (String)oSecond));
            return res;
        }
    };
    HashSet hElements = new HashSet();
    hElements.add("p1");
    hElements.add("p10");
    hElements.add("p11");
    hElements.add("p21");
    hElements.add("p311");
    hElements.add("p4111");
    hElements.add("p4112");
    hElements.add("p4115");
    s.calculateClusters(hElements,c);
    System.out.println(gr.demokritos.iit.jinsect.utils.graphToDot(s.getHierarchy(), true));
}
 
開發者ID:ayushoriginal,項目名稱:Ngram-Graphs,代碼行數:23,代碼來源:SingleLinkClusterer.java


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