ObjectStreamClass 

Introduction

The Java.io.ObjectStreamClass class is Serialization’s descriptor for classes. It contains the name and serialVersionUID of the class. The ObjectStreamClass for a specific class loaded in this Java VM can be found/created using the lookup method.

Class declaration

Following is the declaration for Java.io.ObjectStreamClass class −

public class ObjectStreamClass
   extends Object
      implements Serializable

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Field

Following are the fields for Java.io.ObjectStreamClass class −

  • static ObjectStreamField[] NO_FIELDS − This is the serialPersistentFields value indicating no serializable fields.

Class methods

Sr.No.Method & Description
1Class<?> forClass()This method returns the class in the local VM that this version is mapped to.
2ObjectStreamField getField(String name)This method gets the field of this class by name.
3ObjectStreamField[] getFields()This method returns an array of the fields of this serializable class.
4String getName()This method returns the name of the class described by this descriptor.
5long getSerialVersionUID()This method returns the serialVersionUID for this class.
6static ObjectStreamClass lookup(Class<?> cl)This method finds the descriptor for a class that can be serialized.
7static ObjectStreamClass lookupAny(Class<?> cl)This method returns the descriptor for any class, regardless of whether it implements Serializable.
8String toString()This method returns a string describing this ObjectStreamClass.

Methods inherited

This class inherits methods from the following classes −

  • Java.io.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *