ObjectStreamClass (Java SE 13 & JDK 13 )
- All Implemented Interfaces:
Serializable
public class ObjectStreamClass extends Object implements Serializable
- Since:
- 1.1
- See Also:
ObjectStreamField, Object Serialization Specification, Section 4, Class Descriptors, Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static ObjectStreamField[]NO_FIELDSserialPersistentFields value indicating no serializable fields
-
Method Summary
Modifier and Type Method Description Class<?>forClass()Return the class in the local VM that this version is mapped to.
ObjectStreamFieldgetField(String name)Get the field of this class by name.
ObjectStreamField[]getFields()Return an array of the fields of this serializable class.
StringgetName()Returns the name of the class described by this descriptor.
longgetSerialVersionUID()Return the serialVersionUID for this class.
static ObjectStreamClasslookup(Class<?> cl)Find the descriptor for a class that can be serialized.
static ObjectStreamClasslookupAny(Class<?> cl)Returns the descriptor for any class, regardless of whether it implements
Serializable.StringtoString()Return a string describing this ObjectStreamClass.
-
Field Details
-
NO_FIELDS
serialPersistentFields value indicating no serializable fields
-
-
Method Details
-
lookup
Find the descriptor for a class that can be serialized. Creates an ObjectStreamClass instance if one does not exist yet for class. Null is returned if the specified class does not implement java.io.Serializable or java.io.Externalizable.
- Parameters:
cl- class for which to get the descriptor- Returns:
- the class descriptor for the specified class
-
lookupAny
Returns the descriptor for any class, regardless of whether it implements
Serializable.- Parameters:
cl- class for which to get the descriptor- Returns:
- the class descriptor for the specified class
- Since:
- 1.6
-
getName
Returns the name of the class described by this descriptor. This method returns the name of the class in the format that is used by the
Class.getName()method.- Returns:
- a string representing the name of the class
-
getSerialVersionUID
public long getSerialVersionUID()
Return the serialVersionUID for this class. The serialVersionUID defines a set of classes all with the same name that have evolved from a common root class and agree to be serialized and deserialized using a common format. NonSerializable classes have a serialVersionUID of 0L.
- Returns:
- the SUID of the class described by this descriptor
-
forClass
public Class<?> forClass()
Return the class in the local VM that this version is mapped to. Null is returned if there is no corresponding local class.
- Returns:
- the
Classinstance that this descriptor represents
-
getFields
Return an array of the fields of this serializable class.
- Returns:
- an array containing an element for each persistent field of this class. Returns an array of length zero if there are no fields.
- Since:
- 1.2
-
getField
Get the field of this class by name.
- Parameters:
name- the name of the data field to look for- Returns:
- The ObjectStreamField object of the named field or null if there is no such named field.
-
toString
Return a string describing this ObjectStreamClass.
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.