code: public static int multiplyExact(int x, int y) {
          long r = (long)x * (long)y;
          if ((int)r != r) {
              throw new ArithmeticException("integer overflow");
          }
          return (int)r;
      }
docs: Returns the product of the 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