code: private static int mulPosAndCheck(final int x, final int y) {
          /* assert x>=0 && y>=0; */
          final long m = (long) x * (long) y;
          if (m > Integer.MAX_VALUE) {
              throw new ArithmeticException("overflow: mulPos");
          }
          return (int) m;
      }
docs: Multiply two non-negative integers, checking for overflow.
  
  @param x
  a non-negative factor
  @param y
  a non-negative factor
  @return the product <code>x*y</code>
  @throws ArithmeticException
  if the result can not be represented as an int