Module 3.1: Serialization

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/37

encourage image

There's no tags or description

Looks like no tags are added yet.

38 Terms

1
New cards

Serialization

The process of converting an object's state into a byte stream. This allows the object's data to be saved to a file, stored in a database, or transmitted over a network so that it can be reconstructed later.

2
New cards

Deserialization

The reverse process of serialization. It converts a previously serialized byte stream back into a Java object, restoring its saved state. The object's class must be available to the Java Virtual Machine (JVM).

3
New cards

Byte Stream

A sequence of bytes representing serialized object data. It allows an object's state to be stored or transmitted in binary form.

4
New cards

Object State

The collection of values stored in an object's instance variables at a particular time. Serialization preserves the serializable portions of this state so they can be restored later.

5
New cards

Object Graph

A structure consisting of an object and the other objects connected to it through references. Serialization can convert an entire graph of serializable objects into a byte stream.

6
New cards

Object Persistence

The ability to preserve an object's state beyond the execution of a program. Serialization supports persistence by allowing objects to be saved and restored later.

7
New cards

Network Transmission

The process of transferring serialized objects between systems or Java Virtual Machines. It allows distributed applications to exchange object data through a network.

8
New cards

Java Virtual Machine (JVM)

The runtime environment responsible for executing Java bytecode. During serialization and deserialization, the JVM handles object conversion, reconstruction, and compatibility checks.

9
New cards

Serializable Interface

A Java interface that allows objects of a class to be serialized. A class implements java.io.Serializable to indicate that its instances support Java's standard serialization mechanism.

10
New cards

Marker Interface

An interface that does not declare methods but identifies a class as having a particular capability. Serializable is a marker interface because it tells the JVM that objects of the class can be serialized.

11
New cards

implements Serializable

A Java declaration that marks a class as serializable. For example, class Student implements Serializable indicates that Student objects can participate in Java serialization.

12
New cards

NotSerializableException

An exception thrown when Java attempts to serialize an object that does not support serialization. It may occur when a class does not implement Serializable or when its object graph contains a non-serializable object.

13
New cards

ObjectOutputStream

A Java class used to write objects to an output stream through serialization. It converts objects into byte streams that can be stored or transmitted.

14
New cards

FileOutputStream

A Java class used to write bytes into a file. During serialization, it is commonly combined with ObjectOutputStream to save serialized objects.

15
New cards

writeObject()

A method of ObjectOutputStream that serializes an object and writes its data to an output stream. It is used when saving Java objects.

16
New cards

ObjectInputStream

A Java class used to read serialized objects from an input stream. It reconstructs objects from previously saved byte streams.

17
New cards

FileInputStream

A Java class used to read bytes from a file. During deserialization, it is commonly combined with ObjectInputStream to retrieve stored object data.

18
New cards

readObject()

A method of ObjectInputStream that reads serialized data and reconstructs an object. The method returns an Object reference, which is commonly cast to the expected class type.

19
New cards

Type Casting

The process of treating an object reference as another compatible type. During deserialization, casting is commonly used to convert the result of readObject() into the original class type, such as (Student) in.readObject().

20
New cards

IOException

An exception that indicates a problem during input or output operations. It can occur when reading or writing serialized data, such as when a file cannot be accessed or a stream operation fails.

21
New cards

ClassNotFoundException

An exception that can occur during deserialization when the JVM cannot locate the class required to reconstruct a serialized object.

22
New cards

Serialized File (.ser)

A file commonly used to store serialized Java objects. It contains binary data representing the object's saved state. This extension is a convention, not a requirement.

23
New cards

transient

A Java keyword used to prevent a particular instance field from being included in the default serialization process. It is commonly applied to sensitive or temporary data, such as passwords.

24
New cards

Transient Field

An instance variable declared using the transient keyword. Its value is excluded from default serialization, and when the object is deserialized, the field receives its default value unless another mechanism restores it.

25
New cards

Default Field Values

The values automatically assigned to fields when no explicit value is provided.

26
New cards

serialVersionUID

A unique version identifier associated with a serializable class. The JVM uses it to check whether a serialized object's class version is compatible with the class used during deserialization.

27
New cards

InvalidClassException

An exception that can occur during deserialization when the serialized object's class information is incompatible with the available class. A mismatch in serialVersionUID can cause this exception.

28
New cards

Version Compatibility

The ability to deserialize previously saved objects using a compatible version of their original class. Declaring an explicit serialVersionUID helps manage class version changes, although matching identifiers do not guarantee complete compatibility.

29
New cards

Externalizable

A Java interface that gives programmers greater control over serialization and deserialization. Unlike standard Serializable, it requires the programmer to manually define how object data is written and read.

30
New cards

Manual Serialization

A process where the programmer explicitly determines which values are written and how they are represented. This is accomplished through the Externalizable interface and its required methods.

31
New cards

writeExternal()

A method required by the Externalizable interface. It allows programmers to specify which object fields are written to an output stream and how those values are stored.

32
New cards

readExternal()

A method required by the Externalizable interface. It defines how serialized data is read and used to restore an object's fields.

33
New cards

Public No-Argument Constructor

A constructor that accepts no parameters and is publicly accessible. Classes implementing Externalizable must provide one so Java can create an instance during deserialization.

34
New cards

Static Fields

Variables declared using the static keyword that belong to the class rather than individual objects. Static fields are not included in standard object serialization because serialization preserves instance state rather than class-level state.

35
New cards

Circular Object References

A situation where objects reference one another in a cycle. These relationships can make object graphs complex. Java's standard serialization handles circular references, but custom serialization logic may require special care.

36
New cards

Security Vulnerabilities in Deserialization

Security risks that may arise when applications deserialize data from untrusted sources. Malicious serialized data can potentially trigger unsafe behavior, making untrusted deserialization dangerous.

37
New cards

Input Validation

The process of checking incoming data before processing it. The module emphasizes validating data from untrusted sources to reduce risks associated with deserialization.

38
New cards

Try-With-Resources

A Java statement that automatically closes resources such as file and object streams after use. It helps prevent resource leaks during serialization and deserialization.