marker-interfaces

Java: What can and what can't be serialized?

☆樱花仙子☆ 提交于 2019-11-28 06:51:08
If the Serializable interface is just a Marker-Interface that is used for passing some-sort of meta-data about classes in java - I'm a bit confused: After reading the process of java's serialization algorithm (metadata bottom-to-top, then actual instance data top-to-bottom), I can't really understand what data cannot be processed through that algorithm. In short and formal: What data may cause the NotSerializableException ? How should I know that I am not supposed to add the implements Serializable clause for my class? When you are talking about NotSerializableException it is throw when you

Java: What can and what can't be serialized?

纵然是瞬间 提交于 2019-11-27 01:31:45
问题 If the Serializable interface is just a Marker-Interface that is used for passing some-sort of meta-data about classes in java - I'm a bit confused: After reading the process of java's serialization algorithm (metadata bottom-to-top, then actual instance data top-to-bottom), I can't really understand what data cannot be processed through that algorithm. In short and formal: What data may cause the NotSerializableException ? How should I know that I am not supposed to add the implements

Marker Interfaces in Java?

試著忘記壹切 提交于 2019-11-26 12:02:42
I was being taught that Marker interface in Java is an empty interface and is used to signal to compiler or JVM that the objects of the class implementing this interface must be treated in a special way, like serializing, cloning, etc. But lately I have learned that it actually has nothing to do with the compiler or the JVM. For example, in case of Serializable interface the method writeObject(Object) of ObjectOutputStream does something like instanceOf Serializable to detect whether the class implements Serializable & throws NotSerializableException accordingly. Everything is handled in the

What is the use of marker interfaces in Java?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 02:08:51
问题 When there is nothing to implement in the marker interfaces like Serializable . . what is the use of implementing it? 回答1: In earlier versions of Java, Marker Interfaces were the only way to declare metadata about a class. For example, the Serializable Marker Interface lets the author of a class say that their class will behave correctly when serialized and deserialized. In modern Java, marker interfaces have no place. They can be completely replaced by Annotations, which allow for a very