SerialJavaObject (Java SE 26 & JDK 26)
Description: declaration: module: java.sql.rowset, package: javax.sql.rowset.serial, class: SerialJavaObject
Keywords: javax.sql.rowset.serial.SerialJavaObject class

# Class SerialJavaObject

java.lang.Object
javax.sql.rowset.serial.SerialJavaObject

All Implemented Interfaces:
  `Serializable, Cloneable`

public class SerialJavaObject extends Object implements Serializable, Cloneable
A serializable mapping in the Java programming language of an SQL `JAVA_OBJECT` value. Assuming the Java object implements the `Serializable` interface, this class simply wraps the serialization process.

If however, the serialization is not possible because the Java object is not immediately serializable, this class will attempt to serialize all non-static members to permit the object state to be serialized. Static or transient fields cannot be serialized; an attempt to serialize them will result in a `SerialException` object being thrown.

## Thread safety

A SerialJavaObject is not safe for use by multiple concurrent threads. If a SerialJavaObject is to be used by more than one thread then access to the SerialJavaObject should be controlled by appropriate synchronization.

Since:
  1.5
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SerialJavaObject(Object obj)`
  Constructor for `SerialJavaObject` helper class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  Returns a clone of this `SerialJavaObject`.
  `boolean`
  `equals(Object o)`
  Compares this SerialJavaObject to the specified object.
  `Field[]`
  `getFields()`
  Returns an array of `Field` objects that contains each field of the object that this helper class is serializing.
  `Object`
  `getObject()`
  Returns an `Object` that is a copy of this `SerialJavaObject` object.
  `int`
  `hashCode()`
  Returns a hash code for this SerialJavaObject.

  ### Methods declared in class Object

  `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(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`
  `wait(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.

- ## Constructor Details

  - ### SerialJavaObject

    public SerialJavaObject(Object obj) throws SerialException
    Constructor for `SerialJavaObject` helper class.
    Parameters:
      `obj` - the Java `Object` to be serialized
    Throws:
      `SerialException` - if the object is found not to be serializable

- ## Method Details

  - ### getObject

    public Object getObject() throws SerialException
    Returns an `Object` that is a copy of this `SerialJavaObject` object.
    Returns:
      a copy of this `SerialJavaObject` object as an `Object` in the Java programming language
    Throws:
      `SerialException` - if the instance is corrupt

  - ### getFields

    public Field[] getFields() throws SerialException
    Returns an array of `Field` objects that contains each field of the object that this helper class is serializing.
    Returns:
      an array of `Field` objects
    Throws:
      `SerialException` - if an error is encountered accessing the serialized object
    See Also:
      - `Class.getFields()`

  - ### equals

    public boolean equals(Object o)
    Compares this SerialJavaObject to the specified object. The result is `true` if and only if the argument is not `null` and is a `SerialJavaObject` object that is identical to this object
    Overrides:
      `equals` in class `Object`
    Parameters:
      `o` - The object to compare this `SerialJavaObject` against
    Returns:
      `true` if the given object represents a `SerialJavaObject` equivalent to this SerialJavaObject, `false` otherwise
    See Also:
      - `Object.hashCode()`
      - `HashMap`

  - ### hashCode

    public int hashCode()
    Returns a hash code for this SerialJavaObject. The hash code for a `SerialJavaObject` object is taken as the hash code of the `Object` it stores
    Overrides:
      `hashCode` in class `Object`
    Returns:
      a hash code value for this object.
    See Also:
      - `Object.equals(java.lang.Object)`
      - `System.identityHashCode(Object)`

  - ### clone

    public Object clone()
    Returns a clone of this `SerialJavaObject`.
    Overrides:
      `clone` in class `Object`
    Returns:
      a clone of this SerialJavaObject
    See Also:
      - `Cloneable`