public Object readList(AbstractHessianInput in, int length)
    throws IOException
  {
    if (length >= 0) {
      Object []data = createArray(length);

      in.addRef(data);
      
      if (_componentType != null) {
        for (int i = 0; i < data.length; i++)
          data[i] = in.readObject(_componentType);
      }
      else {
        for (int i = 0; i < data.length; i++)
          data[i] = in.readObject();
      }

      in.readListEnd();

      return data;
    }
    else {
      ArrayList list = new ArrayList();

      in.addRef(list);

      if (_componentType != null) {
        while (! in.isEnd())
          list.add(in.readObject(_componentType));
      }
      else {
        while (! in.isEnd())
          list.add(in.readObject());
      }

      in.readListEnd();

      Object []data = createArray(list.size());
      for (int i = 0; i < data.length; i++)
        data[i] = list.get(i);

      return data;
    }
  }