void cacheVisitedState(
     APTPreprocHandler.State inputState,
     APTPreprocHandler outputHandler,
     FilePreprocessorConditionState pcState) {
   if (cacheStates && inputState.isCompileContext()) {
     stateCacheLock.writeLock().lock();
     try {
       if ((stateCache.isEmpty() || APTHandlersSupport.getIncludeStackDepth(inputState) == 1)
           && isCacheableState(inputState)) {
         if (stateCache.size() == CACHE_SIZE) {
           int min = Integer.MAX_VALUE;
           APTPreprocHandler.StateKey key = null;
           for (Map.Entry<APTPreprocHandler.StateKey, Value> entry : stateCache.entrySet()) {
             if (entry.getValue().value.get() == null) {
               key = entry.getKey();
               break;
             }
             if (entry.getValue().count < min) {
               key = entry.getKey();
               min = entry.getValue().count;
             }
           }
           stateCache.remove(key);
         }
         stateCache.put(
             createKey(inputState),
             new Value(new PreprocessorStatePair(outputHandler.getState(), pcState)));
       }
     } finally {
       stateCacheLock.writeLock().unlock();
     }
   }
 }
 private static APTPreprocHandler.StateKey createKey(APTPreprocHandler.State inputState) {
   return APTHandlersSupport.getStateKey(inputState);
 }