docs: public static Object addListener(Object bag, Object listener)
      {
          if (listener == null) throw new IllegalArgumentException();
          if (listener instanceof Object[]) throw new IllegalArgumentException();
  
          if (bag == null) {
              bag = listener;
          } else if (!(bag instanceof Object[])) {
              bag = new Object[] { bag, listener };
          } else {
              Object[] array = (Object[])bag;
              int L = array.length;
              // bag has at least 2 elements if it is array
              if (L < 2) throw new IllegalArgumentException();
              Object[] tmp = new Object[L + 1];
              System.arraycopy(array, 0, tmp, 0, L);
              tmp[L] = listener;
              bag = tmp;
          }
  
          return bag;
      }