当前位置: 首页>>代码示例>>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;未经允许,请勿转载。