@Override
  public Object[] toArray() {
    synchronized (lock) {
      return Arrays.copyOf(elementData, size);
    }
  }
Checks if the given index is in range. If not, throws an appropriate runtime exception. This
method does *not* check if the index is negative: It is always used immediately prior to an
array access, which throws an ArrayIndexOutOfBoundsException if index is negative.
geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexElemArray.java