code: public static int safeLongToInt(long l) {
          if (l > (long)Integer.MAX_VALUE || l < (long) Integer.MIN_VALUE) {
              throw new IllegalStateException("Cannot convert long to int: " + l);
          }
          return (int)l;
      }
docs: /* ---- Convert 8-byte signed long to fewer bytes. -----