code: public static int addExact(int x, int y) {
          int r = x + y;
          // HD 2-12 Overflow iff both arguments have the opposite sign of the result
          if (((x ^ r) & (y ^ r)) < 0) {
              throw new ArithmeticException("integer overflow");
          }
          return r;
      }
docs: Returns the sum of its arguments,
  throwing an exception if the result overflows an {@code int}.
  
  @param x the first value
  @param y the second value
  @return the result
  @throws ArithmeticException if the result overflows an int
  @since 1.8