Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Fields](https://developer.android.com/reference/java/io/ObjectStreamClass#lfields) \| [Methods](https://developer.android.com/reference/java/io/ObjectStreamClass#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/io/ObjectStreamClass#inhmethods)

# ObjectStreamClass

` public class ObjectStreamClass `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/io/Serializable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.io.ObjectStreamClass |

<br />

*** ** * ** ***

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.

The algorithm to compute the SerialVersionUID is described in [Object Serialization Specification, Section 4.6, Stream Unique Identifiers](https://docs.oracle.com/javase/8/docs/platform/serialization/spec/class.html#4100).
**See also:**

- `https://developer.android.com/reference/java/io/ObjectStreamField`
- [Object Serialization Specification, Section 4, Class Descriptors](https://docs.oracle.com/javase/8/docs/platform/serialization/spec/class.html)

## Summary

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/java/io/ObjectStreamField` | `https://developer.android.com/reference/java/io/ObjectStreamClass#NO_FIELDS` serialPersistentFields value indicating no serializable fields |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#forClass()() ` Return the class in the local VM that this version is mapped to. |
| ` https://developer.android.com/reference/java/io/ObjectStreamField` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#getField(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Get the field of this class by name. |
| ` https://developer.android.com/reference/java/io/ObjectStreamField` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#getFields()() ` Return an array of the fields of this serializable class. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#getName()() ` Returns the name of the class described by this descriptor. |
| ` long` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#getSerialVersionUID()() ` Return the serialVersionUID for this class. |
| ` static https://developer.android.com/reference/java/io/ObjectStreamClass` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#lookup(java.lang.Class<?>)(https://developer.android.com/reference/java/lang/Class<?> cl) ` Find the descriptor for a class that can be serialized. |
| ` static https://developer.android.com/reference/java/io/ObjectStreamClass` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#lookupAny(java.lang.Class<?>)(https://developer.android.com/reference/java/lang/Class<?> cl) ` Returns the descriptor for any class, regardless of whether it implements `https://developer.android.com/reference/java/io/Serializable`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/io/ObjectStreamClass#toString()() ` Return a string describing this ObjectStreamClass. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Fields

### NO_FIELDS

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final ObjectStreamField[] NO_FIELDS
```

serialPersistentFields value indicating no serializable fields

<br />

## Public methods

### forClass

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | the `Class` instance that this descriptor represents <br /> |

### getField

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ObjectStreamField getField (String name)
```

Get the field of this class by name.

<br />

| Parameters ||
|---|---|
| `name` | `String`: the name of the data field to look for <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/ObjectStreamField` | The ObjectStreamField object of the named field or null if there is no such named field. <br /> |

### getFields

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ObjectStreamField[] getFields ()
```

Return an array of the fields of this serializable class.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/ObjectStreamField` | an array containing an element for each persistent field of this class. Returns an array of length zero if there are no fields. <br /> |

### getName

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String 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 `https://developer.android.com/reference/java/lang/Class#getName()` method.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representing the name of the class <br /> |

### getSerialVersionUID

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `long` | the SUID of the class described by this descriptor <br /> |

### lookup

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static ObjectStreamClass lookup (Class<?> cl)
```

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.

<br />

| Parameters ||
|---|---|
| `cl` | `Class`: class for which to get the descriptor <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/ObjectStreamClass` | the class descriptor for the specified class <br /> |

### lookupAny

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static ObjectStreamClass lookupAny (Class<?> cl)
```

Returns the descriptor for any class, regardless of whether it implements `https://developer.android.com/reference/java/io/Serializable`.

<br />

| Parameters ||
|---|---|
| `cl` | `Class`: class for which to get the descriptor <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/ObjectStreamClass` | the class descriptor for the specified class <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Return a string describing this ObjectStreamClass.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |