private void checkBeforeInvoke(int pcount, Object params) throws IllegalArgumentException {
    if (pcount == 0) {
      if (params != null) {
        throw new IllegalArgumentException(
                "The number of parameters in the command is 0," +
                "but the params isn't null.");
      }
    }
    else if (pcount == 1) {
      if ((params instanceof Object[]) && (((Object[]) params).length != 1)) {
        throw new IllegalArgumentException(
                "The number of parameters in the command is 1," +
                " but the params is an array of length more than 1.");
      }
    }
    else {
      if (!(params instanceof Object[]) || (((Object[]) params).length != pcount)) {
        throw new IllegalArgumentException(
                "The number of parameters in the command more that 1," +
                " but the params is an array of length isn't equal it.");
      }
    }
  }