code: private static int addAndCheck(final int x, final int y) {
          final long s = (long) x + (long) y;
          if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) {
              throw new ArithmeticException("overflow: add");
          }
          return (int) s;
      }
docs: Add two integers, checking for overflow.
  
  @param x
  an addend
  @param y
  an addend
  @return the sum <code>x+y</code>
  @throws ArithmeticException
  if the result can not be represented as an int