CodeGym
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • Externalizable: fine-tuning serialization

    JAVA 25 SELF
    Level 43, Lesson 2
    Extending basic serialization in Java: when the automation of Serializable is not enough, the manual contract Externalizable with methods writeExternal/ readExternal comes to the rescue. In this lecture, we examine how to fully control the data format, reduce file size, and maintain backward compatibility; we compare it with the streams ObjectOutputStream/ ObjectInputStream, and show examples, pros/cons, and common pitfalls (the required public no-arg constructor, write/read order, etc.).
    Available
  • Configuring serialization behavior: custom methods

    JAVA 25 SELF
    Level 43, Lesson 3
    In this lecture, we examine how to influence the serialization and deserialization process in Java using the methods writeReplace and readResolve: why replace an object with a proxy, how to preserve a singleton, what to do with immutable objects, and how this relates to writeObject/ readObject. Step-by-step practice, a Mermaid flowchart of the operation flow, and a breakdown of common mistakes.
    Available
  • Serialization security: best practices

    JAVA 25 SELF
    Level 43, Lesson 4
    A practical guide to safe serialization in Java: why deserialization from untrusted sources is dangerous, how to defend using ObjectInputFilter, the transient keyword, an explicit serialVersionUID, type checks via instanceof, and alternative exchange formats (JSON/Proto). Inside — clear code examples, allowlist-based class filtering, and a breakdown of common mistakes.
    Available
  • Serialization of nested objects: nuances

    JAVA 25 SELF
    Level 44, Lesson 0
    In this lecture, we examine how Java performs deep serialization of an object graph: what happens to reference fields, why all nested objects must implement Serializable, how to avoid NotSerializableException, and in which cases the transient modifier helps. With examples, we will show serialization/deserialization of objects with nesting, collections, and cyclic references, and we will also break down common mistakes related to serialVersionUID and large object graphs.
    Available
  • Nested and Hierarchical Objects: Serializing Graphs

    JAVA 25 SELF
    Level 44, Lesson 1
    How Java serializes complex data structures: from nested collections and inheritance hierarchies to cyclic object graphs. We’ll examine why serialization of Map<String, List<Book>> works, how concrete subtype information is preserved in List<Animal>, what the reference mechanism does in cycles, and which pitfalls you may encounter. We’ll discuss the roles of ObjectOutputStream/ ObjectInputStream, the writeObject/ readObject methods, the serialVersionUID field, and the transient modifier.
    Available
  • Cyclic references problem: detection and handling

    JAVA 25 SELF
    Level 44, Lesson 2
    We examine what cyclic references are in object graphs, why they are dangerous for serialization, and how to deal with them. It is shown how Java’s standard streams — ObjectOutputStream/ ObjectInputStream — automatically track already encountered objects and write references (handles), preventing StackOverflowError. We will cover the pitfalls of custom serialization ( writeObject/ readObject, defaultWriteObject/ defaultReadObject), as well as strategies for handling cycles in JSON: annotations @JsonIdentityInfo, @JsonBackReference/ @JsonManagedReference, excluding fields via transient, and using identifiers.
    Available
  • Object identity in binary serialization

    JAVA 25 SELF
    Level 44, Lesson 3
    How Java preserves and restores object identity during binary serialization: why equivalence via a. equals( b) is not the same as identity ( a == b), how ObjectOutputStream/ ObjectInputStream track the object graph and write “back references” instead of duplicates, why this works correctly with cycles, and how the methods writeReplace() and readResolve() can affect the resulting identity. Walkthrough with examples: cycles, shared references, practice, and common mistakes.
    Available
  • Review of common mistakes in collection serialization

    JAVA 25 SELF
    Level 44, Lesson 4
    In this lecture, we break down the most frequent issues when serializing collections: from java.io.NotSerializableException (when elements do not implement Serializable) and generics pitfalls with ClassCastException to class version incompatibilities via serialVersionUID. We will discuss nuances of immutable collections ( List.of(), Set.of(), Map.of()), the behavior of transient/ static fields, as well as performance and file size, where streaming writes and compression ( GZIPOutputStream) help. You will get practical tips, code examples, and recommendations for safe deserialization ( readObject/ writeObject).
    Available
  • Binary serialization pitfalls: security, compatibility

    JAVA 25 SELF
    Level 45, Lesson 0
    In this lecture we examine the risks of binary serialization in Java: why deserialization from untrusted sources is dangerous (“gadget chains”, RCE), what threats special methods like readObject and readResolve pose, and how to defend yourself (whitelisting, opting for JSON/ XML, safe libraries such as Jackson). We will look in detail at class version compatibility and the role of the serialVersionUID field, behavior on InvalidClassException, the constraints of transient/ static, performance, as well as best practices and common mistakes.
    Available
  • Serialization of generic collections: specifics

    JAVA 25 SELF
    Level 45, Lesson 1
    We analyse how type erasure ( type erasure) affects serialization of generic collections: why at runtime List<String> and List<Integer> are the same ArrayList, what exactly is written and read via ObjectOutputStream/ ObjectInputStream, where ClassCastException and warnings about unchecked casts come from. We will show examples with nested collections, Map/ Set, mention Gson/ Jackson, and formulate practices for safe deserialization.
    Available
  • Compatibility and backward compatibility in serialization

    JAVA 25 SELF
    Level 45, Lesson 2
    We break down how to evolve serializable classes without breaking data: why you should fix serialVersionUID, how the JVM checks compatibility, which changes are safe (adding/removing fields) and which are critical (type changes, moving a class to another package). We’ll show the role of transient/ static, custom serialization techniques via writeObject/ readObject, how binary serialization differs from XML/JSON, strategies to ensure compatibility, and common pitfalls (for example, InvalidClassException).
    Available
  • Migration and versioning of serialized data

    JAVA 25 SELF
    Level 45, Lesson 3
    How to safely evolve serializable classes in production: what happens when fields and types change, how class versioning works via serialVersionUID, when to change it and when to keep it, how to apply “lazy” migration via readObject/ readFields and in-place conversion, and what advanced techniques exist such as ObjectInputStream.readClassDescriptor(). We will go through a complete practical scenario with two class versions and typical mistakes, including traps like InvalidClassException.
    Available
  • 1
  • ...
  • 19
  • 20
  • 21
  • 22
  • 23
  • ...
  • 30
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym