This should really be calling ensurePowerOfTwo (currently in jarray2.cpp), which should also probably be moved into a header file.