guava/src/com/google/common/math/IntMath.java
@Beta
  public static int ceilingPowerOfTwo(int x) {
    checkPositive("x", x);
    if (x > MAX_SIGNED_POWER_OF_TWO) {
      throw new ArithmeticException("ceilingPowerOfTwo(" + x + ") not representable as an int");
    }
    return 1 << -Integer.numberOfLeadingZeros(x - 1);
  }
@Beta
  public static int ceilingPowerOfTwo(int x) {
    checkPositive("x", x);
    if (x > MAX_SIGNED_POWER_OF_TWO) {
      throw new ArithmeticException("ceilingPowerOfTwo(" + x + ") not representable as an int");
    }
    return 1 << -Integer.numberOfLeadingZeros(x - 1);
  }
Returns the smallest power of two greater than or equal to {@code x}. This is equivalent to
{@code checkedPow(2, log2(x, CEILING))}.

@throws IllegalArgumentException if {@code x <= 0}
@throws ArithmeticException of the next-higher power of two is not representable as an {@code
int}, i.e. when {@code x > 2^30}
@since 20.0