Author Archives: Stanislav_Panteleev

Java.Serialization.When should I change the value of the serialVersionUID field?

🧠 Purpose Recap: serialVersionUID It’s used by Java to detect if the class used during deserialization is compatible with the class that was used during serialization. If the serialVersionUID values differ → 💥 InvalidClassException

Posted in Без рубрики | Comments Off on Java.Serialization.When should I change the value of the serialVersionUID field?

Java.Serialization.What is the role of the serialVersionUID field in serialization?

🧠 What is serialVersionUID? serialVersionUID is a special static final long field that acts like a version number for a class.It’s used to ensure that a serialized object can be deserialized correctly, even if the class has changed.

Posted in Без рубрики | Comments Off on Java.Serialization.What is the role of the serialVersionUID field in serialization?

Java.Serialization.How can I create my own serialization protocol?

✅ Example: Manual Serialization Protocol 🔹 Step 1: Define a class with custom writeTo() and readFrom() methods 🔹 Step 2: Save the object manually 🔹 Step 3: Load the object manually 🔐 Bonus: Add encryption, compression, versioning ➕ Versioning Add … Continue reading →

Posted in Без рубрики | Comments Off on Java.Serialization.How can I create my own serialization protocol?

Java.Serialization.How can I prevent serialization?

🛑 1. Prevent Serialization of a Whole Class Option A: Don’t implement Serializable 🚫 If a class doesn’t implement Serializable, it can’t be serialized.

Posted in Без рубрики | Comments Off on Java.Serialization.How can I prevent serialization?

Java.Serialization.What effect do the static and final field modifiers have on serializability?

🔍 1. static Fields ✅ Summary: static fields are never serialized. Why? static means the field belongs to the class itself, not to any specific object. Serialization is all about saving the state of an object — and static fields … Continue reading →

Posted in Без рубрики | Comments Off on Java.Serialization.What effect do the static and final field modifiers have on serializability?

Java.Serialization.What does the transient keyword mean?

What does the transient keyword mean? 📘 Syntax

Posted in Без рубрики | Comments Off on Java.Serialization.What does the transient keyword mean?

Java.Serialization.How can I exclude fields from serialization?

🚫 Use the transient Keyword When a field is marked as transient, Java skips it during serialization — it will not be written to the stream, and when deserialized, it will be set to its default value. 🔄 When deserialized:

Posted in Без рубрики | Comments Off on Java.Serialization.How can I exclude fields from serialization?

Java.Serialization.CompressionExample

Posted in Без рубрики | Comments Off on Java.Serialization.CompressionExample

Java.Serialization.How can I change the default serialization/deserialization behavior?

🔧 Ways to Customize Java Serialization If your class implements Serializable, you can define two special methods: These allow you to manually control what gets written to and read from the stream.

Posted in Без рубрики | Comments Off on Java.Serialization.How can I change the default serialization/deserialization behavior?

Java.Serialization.Describe the serialization/deserialization process using Serializable.

🔹 1. Mark the Class as Serializable To make a class eligible for serialization: ✅ This tells Java: “You can save and restore objects of this class.”

Posted in Без рубрики | Comments Off on Java.Serialization.Describe the serialization/deserialization process using Serializable.