Serializable identification by JVM




How JVM identify whether a class is Serializable? What exactly the operations JVM perform when it come to know that the class is serializable?


In: java Asked By: [Chiranjeevi] (Anonymously)
imagenes de pastilla viagra
Answer #1

Hi there,

as the Java API states, the JVM looks for the marker interface Serializable – or any of it’s extensions like Externalizable. For more complex serializing, use writeObject/readObject methods :

“Serializability of a class is enabled by the class implementing the interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

To allow subtypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype’s public, protected, and (if accessible) package fields. The subtype may assume this responsibility only if the class it extends has an accessible no-arg constructor to initialize the class’s state. It is an error to declare a class Serializable if this is not the case. The error will be detected at runtime.

During deserialization, the fields of non-serializable classes will be initialized using the public or protected no-arg constructor of the class. A no-arg constructor must be accessible to the subclass that is serializable. The fields of serializable subclasses will be restored from the stream. viagra cost without insurance

When traversing a graph, an object may be encountered that does not support the Serializable interface. In this case the NotSerializableException will be thrown and will identify the class of the non-serializable object.” viagra ad actress black

As a comparizon between Serializable and Externalizable, the Java API states that:

“Only the identity of the class of an Externalizable instance is written in the serialization stream and it is the responsibility of the class to save and restore the contents of its instances. The writeExternal and readExternal methods of the Externalizable interface are implemented by a class to give the class complete control over the format and contents of the stream for an object and its supertypes. These methods must explicitly coordinate with the supertype to save its state. These methods supersede customized implementations of writeObject and readObject methods.
Object Serialization uses the Serializable and Externalizable interfaces. Object persistence mechanisms can use them as well. Each object to be stored is tested for the Externalizable interface. If the object supports Externalizable, the writeExternal method is called. If the object does not support Externalizable and does implement Serializable, the object is saved using ObjectOutputStream.
When an Externalizable object is reconstructed, an instance is created using the public no-arg constructor, then the readExternal method called. Serializable objects are restored by reading them from an ObjectInputStream.
An Externalizable instance can designate a substitution object via the writeReplace and readResolve methods documented in the Serializable interface.”

Moreover, as stated here: buy sildenafil for dogs

and here:

The default serialization process DOES NOT serialize the transient and private members and any state of an upper hierarchy graph object or delegated inner object which does not implement Serializable. If features like these are required by the project, then the developer must read this:

Answers Answered By: aiboogie [ Grey Star Level] viagra capsule hindi
what does a viagra prescription look like
fanda pharmacy hong kong viagra

Answer this Question

Enter name & email to post an Answer. You can also Login / Join us

For a better management of this site please consider Logging in / Joining us before posting a Question. It makes everithing easier for us.

Please enter the captcha code bellow.
Logged in users don't have to use captchas. Don't have an account? Join us!

cialis cost per pill 2015
otc viagra
sildenafil 50mg uk

cialis pills 20 mg

cialis 20 mg 8 tabl
Link Exchange:

You can add url to the best of the internet directory. Our url is added under Reference Directory
cialis tabletten wirkung