code: @Nonnull
    public static byte [] getSerializedByteArray (@Nonnull final Serializable aData)
    {
      ValueEnforcer.notNull (aData, "Data");
  
      try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ())
      {
        // Convert to byte array
        try (final ObjectOutputStream aOOS = new ObjectOutputStream (aBAOS))
        {
          aOOS.writeObject (aData);
        }
  
        // Main sending
        return aBAOS.toByteArray ();
      }
      catch (final NotSerializableException ex)
      {
        throw new IllegalArgumentException ("Not serializable: " + ex.getMessage (), ex);
      }
      catch (final IOException ex)
      {
        throw new IllegalArgumentException ("Failed to write serializable object " +
                                            aData +
                                            " of type " +
                                            aData.getClass ().getName (),
                                            ex);
      }
    }
docs: Convert the passed Serializable object to a serialized byte array.
  
  @param aData
  Source object. May not be <code>null</code>.
  @return A non-<code>null</code> byte array.
  @throws IllegalStateException
  If serialization failed