docs: public void writeNotificationRecords(OutputStream out, NotificationRecord[] value) throws IOException {
          writeStartArray(out);
          if (value == null) {
              writeEndArray(out);
              return;
          }
  
          for (NotificationRecord nr : value) {
              Notification item = nr.getNotification();
              writeArrayItem(out);
              writeStartObject(out);
  
              // Fields common to all notification classes
              Class<?> clazz = item.getClass();
              writeSimpleStringField(out, OM_CLASSNAME, clazz.getName());
              writeStringField(out, OM_TYPE, item.getType());
              ObjectName on = null;
              if (item.getSource() instanceof String) {
                  try {
                      on = new ObjectName((String) item.getSource());
                  } catch (Exception e) {
                  }
              } else {
                  on = (ObjectName) item.getSource();
              }
  
              writeObjectNameField(out, OM_SOURCE, on);
              writeLongField(out, OM_SEQUENCENUMBER, item.getSequenceNumber());
              writeLongField(out, OM_TIMESTAMP, item.getTimeStamp());
              writeStringField(out, OM_MESSAGE, item.getMessage());
              writePOJOField(out, OM_USERDATA, item.getUserData());
  
              // Write routing information (host name, server name, server user dir) if this is a routed notification.
              final Map<String, Object> routingInfo = nr.getNotificationTargetInformation().getRoutingInformation();
              if (routingInfo != null) {
                  String hostName = (String) routingInfo.get(ClientProvider.ROUTING_KEY_HOST_NAME);
                  String serverName = (String) routingInfo.get(ClientProvider.ROUTING_KEY_SERVER_NAME);
                  String serverUserDir = (String) routingInfo.get(ClientProvider.ROUTING_KEY_SERVER_USER_DIR);
  
                  writeStringField(out, OM_HOSTNAME, hostName);
                  writeStringField(out, OM_SERVERNAME, serverName);
                  writeStringField(out, OM_SERVERUSERDIR, serverUserDir);
              }
  
              if (clazz == Notification.class) {
              } else if (clazz == AttributeChangeNotification.class) {
                  AttributeChangeNotification v = (AttributeChangeNotification) item;
                  writeStringField(out, OM_ATTRIBUTENAME, v.getAttributeName());
                  writeStringField(out, OM_ATTRIBUTETYPE, v.getAttributeType());
                  writePOJOField(out, OM_OLDVALUE, v.getOldValue());
                  writePOJOField(out, OM_NEWVALUE, v.getNewValue());
              } else if (clazz == JMXConnectionNotification.class) {
                  JMXConnectionNotification v = (JMXConnectionNotification) item;
                  writeStringField(out, OM_CONNECTIONID, v.getConnectionId());
              } else if (clazz == MBeanServerNotification.class) {
                  MBeanServerNotification v = (MBeanServerNotification) item;
                  writeObjectNameField(out, OM_MBEANNAME, v.getMBeanName());
              } else if (clazz == RelationNotification.class) {
                  RelationNotification v = (RelationNotification) item;
                  writeStringField(out, OM_RELATIONID, v.getRelationId());
                  writeStringField(out, OM_RELATIONTYPENAME, v.getRelationTypeName());
                  writeObjectNameField(out, OM_OBJECTNAME, v.getObjectName());
                  String roleName = v.getRoleName();
                  if (roleName == null) {
                      writeObjectNameListField(out, OM_MBEANSTOUNREGISTER, v.getMBeansToUnregister());
                  } else {
                      writeStringField(out, OM_ROLENAME, v.getRoleName());
                      writeObjectNameListField(out, OM_OLDROLEVALUE, v.getOldRoleValue());
                      writeObjectNameListField(out, OM_NEWROLEVALUE, v.getNewRoleValue());
                  }
              } else if (clazz == TimerNotification.class) {
                  TimerNotification v = (TimerNotification) item;
                  writeIntField(out, OM_NOTIFICATIONID, v.getNotificationID());
              } else {
                  // MonitorNotification and TimerAlarmClockNotification are
                  // known, but either the class or the constructor is not
                  // visible, and we have to use base64.
                  // SnmpTableEntryNotification is a sun specific implementation.
                  writeSerializedField(out, OM_SERIALIZED, item);
              }
  
              writeEndObject(out);
          }
          writeEndArray(out);
      }