简体   繁体   English

创建.ser文件后,是否可以编辑.ser java文件中使用的类?

[英]Can classes used in .ser java file be edited after .ser file creation?

I am trying to load a .ser file of a class I made a while back. 我正在尝试加载前一段时间制作的类的.ser文件。

But I'm getting ClassNotFoundException . 但是我正在收到ClassNotFoundException

I'm wondering, is it because I made changes to the class used in those files? 我想知道,是因为我对这些文件中使用的类进行了更改吗? Because the class name is the same, the only changes are some new methods. 因为类名相同,所以唯一的更改是一些新方法。

If this is the case, is there a way I load .ser files that had their classes changed after creation? 如果是这种情况,是否可以加载在创建后更改了类的.ser文件?

java.lang.ClassNotFoundException: ebay.ItemEditObject
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at ebay.EbayMaster.getObjFromFile(EbayMaster.java:750)
at ebay.EbayMaster.createItemsForUpload(EbayMaster.java:340)
at ebay.EbayMaster.ebayRunner(EbayMaster.java:129)
at ebay.EbayMaster.main(EbayMaster.java:92)

I'm wondering, is it because I made changes to the class used in those files? 我想知道,是因为我对这些文件中使用的类进行了更改吗?

No. 没有。

Because the class name is the same, the only changes are some new methods. 因为类名相同,所以唯一的更改是一些新方法。

That could cause an InvalidClassException . 这可能会导致InvalidClassException Not a ClassNotFoundException . 不是ClassNotFoundException

But you aren't getting either of these. 但是您没有得到任何一个。 You're getting FileNotFoundException. 您正在获取FileNotFoundException. The file wasn't found. 找不到文件。 Look again. 再看一遍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以知道Java中.ser文件中的属性? - Is it possible to know the attributes inside a .ser file in Java? 读取 Ser 文件(序列化) - Reading Ser file (Serialization) 与Java中的.txt文件相比,将集合读/写到.ser文件 - reading/writing a set to a .ser file compared to a .txt file in java Java在资源文件夹上创建一个空的.ser文件(如果尚不存在) - Java Create an empty .ser file on resource folder if not exists yet Java程序从服务器中的.ser文件读取对象 - Java program to read objects from a .ser file located in a server 查看通过解压缩.jar文件获得的.ser文件 - Viewing .ser file obtained by extracting a .jar file 如何计算存储在 *.ser 文件中的对象数 - How to count number of objects stored in a *.ser file 用这种方法创建新的.ser文件怎么办? - What is wrong with creating a new .ser file in this method? 在Java编程中,当我们在现有文件上重写时,文件(.txt,.ser等)会被覆盖吗? - in Java Programming, will the file (.txt, .ser etc) get overwritten when we rewrite on existing file? Bazel使用针对ser / Deser的Jackson注释构建并生成Java类 - Bazel build with Jackson annotations for ser/Deser and generate Java classes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM