private void debugCheck() {
		// If the GapList is not used for storing content in KeyListImpl, values may be null
		if (values == null) {
			assert(size == 0 && start == 0 && end == 0);
			assert(gapSize == 0 && gapStart == 0 && gapIndex == 0);
			return;
		}

		assert(size >= 0 && size <= values.length);
		assert(start >=0 && (start < values.length || values.length == 0));
		assert(end >= 0 && (end < values.length || values.length == 0));
		assert(values.length == 0 || (start+size+gapSize) % values.length == end);

		// Check that logical gap index is correct
		assert(gapSize >= 0);
		if (gapSize > 0) {
			assert(gapStart >= 0 && gapStart < values.length);
			// gap may not be at start or end
			assert(gapIndex > 0 && gapIndex < size);
			// gap start may not be the same as start or end
			assert(gapStart != start && gapStart != end);
			// check that logical and phyiscal gap index are correct
			assert(physIndex(gapIndex) == (gapStart+gapSize) % values.length);
		}

		// Check that gap positions contain null values
		if (gapSize > 0) {
			for (int i=gapStart; i<gapStart+gapSize; i++) {
				int pos = (i % values.length);
				assert(values[pos] == null);
			}
		}

		// Check that all end positions contain null values
		if (start < end) {
			for (int i=0; i<start; i++) {
				assert(values[i] == null);
			}
			for (int i=end; i<values.length; i++) {
				assert(values[i] == null);
			}
		} else if (end < start) {
			for (int i=end; i<start; i++) {
				assert(values[i] == null);
			}
		}
	}
Private method to check invariant of GapList.
It is only used for debugging.
jphp-runtime/src/php/runtime/memory/support/GapList.java