IllegalAccessException - 对象的序列化,从非序列继承 [英] IllegalAccessException - Serialization of object that inherits from non-serializable

查看:331
本文介绍了IllegalAccessException - 对象的序列化,从非序列继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我越来越android.widget.ImageView;尝试反序列化我的$ P $当IllegalAccessException pviously序列化对象

I getting android.widget.ImageView; IllegalAccessException when trying to deserialize my previously serialized object

        File presetFile = new File("pathToFile");

        FileInputStream fis = new FileInputStream(presetFile);      
        ObjectInputStream ois = new ObjectInputStream(fis);
        Preset preset = (Preset) ois.readObject();

我猜是有关于ImageView的一些限制,如下解释:

I'm guessing that there is some restriction about ImageView, explanation below:

public class Preset implements Serializable {

    private Date dateOfCreation;
    private int bpm;
    private SoundSwitch[][] switches;

最后SoundSwitch类的头

And finally SoundSwitch class header

public class SoundSwitch extends ImageView implements Serializable{
}

是不是因为ImageView的,我是从继承没有实现Serializable?我必须放弃反序列化这样的对象?

Is that because ImageView that I inherit from doesn't implement Serializable? Do I have to give up on deserializing such object?

推荐答案

这是因为的ImageView 你继承是不可序列的没有一个公共的无参数的构造函数。显然,它已被保护或数据包进入或私人之一。

It is because the ImageView you are inheriting from is non-Serializable and doesn't have a public no-args constructor. Evidently it has a protected or package-access or private one.

这篇关于IllegalAccessException - 对象的序列化,从非序列继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆