code: private void checkForCycles(
          Class<?> target, 
          Class<?> in, 
          Stack<Class<?>> trace) {
          
          for (Field field : in.getDeclaredFields()) {  
              if (field.getAnnotation(Autowired.class) != null) {
                  Class<?> type = field.getType();
                  trace.push(type);
                  
                  if (type.equals(target)) {
                      throw new DependencyCycleException(trace);       
                      
                  } else {
                      checkForCycles(target, type, trace);
                  }
                  
                  trace.pop();
              }
          }    
      }
docs: A simple recursive cycle-checker implementation that records the current
  stack trace as an argument parameter for the purpose of producing an
  accurate error message in the case of an error.
  
  @param target The target type to be checked for cyclic dependencies. This
  should not change across recursive calls to the method.
  @param in The current type, which is an Nth-level dependency for the
  target type. It must not contain a dependency of the target type.
  @param trace The current stack of dependencies, starting with the target
  type itself.