public synchronized int allocateObjectId(boolean needFresh, boolean dataFile) { // TODO refactor: use hash map instead of bit field for object ids needFresh = true; int i; if (needFresh) { i = objectIds.getLastSetBit() + 1; if ((i & 1) != (dataFile ? 1 : 0)) { i++; } while (storageMap.get(i) != null || objectIds.get(i)) { i++; if ((i & 1) != (dataFile ? 1 : 0)) { i++; } } } else { i = objectIds.nextClearBit(0); } if (SysProperties.CHECK && objectIds.get(i)) { throw Message.getInternalError(); } objectIds.set(i); return i; }