@SuppressWarnings("checkstyle:cyclomaticcomplexity") private <T>T constructSubclass(Class<T> cls,Args mode,Stack<Class> stack){
  T cachedValue=getCachedValue(cls);
  if (stack.size() > MAX_STACK_DEPTH) {
    LOG.error("Max stack depth of {} reached when constructing subclass for {}. Returning {}.\n{}",MAX_STACK_DEPTH,cls.getSimpleName(),cachedValue,stack);
    return cachedValue;
  }
  if (stack.contains(cls)) {
    LOG.error("Recursive constructors for subclass for {}. Returning {}.\n{}",cls.getSimpleName(),cachedValue,stack);
    return cachedValue;
  }
  stack.push(cls);
  try {
    for (    Class<?> subclass : getClasses()) {
      if (cls.isAssignableFrom(subclass) && !Modifier.isAbstract(subclass.getModifiers())) {
        try {
          @SuppressWarnings("unchecked") T arg=constructObject((Class<T>)subclass,mode,stack);
          if (arg != null) {
            return arg;
          }
        }
 catch (        InstantiationException e) {
          LOG.debug("Instantiation exception : {}",e);
        }
      }
    }
  }
 catch (  ClassNotFoundException|IOException ignore) {
  }
 finally {
    stack.pop();
  }
  return cachedValue;
}

@ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) private < T > T constructSubclass ( Class < T > cls , Args mode , Stack < Class > stack ) { T cachedValue = getCachedValue ( cls ) ; if ( stack . size ( ) > MAX_STACK_DEPTH ) { LOG . error ( "Max stack depth of {} reached when constructing subclass for {}. Returning {}.\n{}" , MAX_STACK_DEPTH , cls . getSimpleName ( ) , cachedValue , stack ) ; return cachedValue ; } if ( stack . contains ( cls ) ) { LOG . error ( "Recursive constructors for subclass for {}. Returning {}.\n{}" , cls . getSimpleName ( ) , cachedValue , stack ) ; return cachedValue ; } stack . push ( cls ) ; try { for ( Class < ? > subclass : getClasses ( ) ) { if ( cls . isAssignableFrom ( subclass ) && ! Modifier . isAbstract ( subclass . getModifiers ( ) ) ) { try { @ SuppressWarnings ( "unchecked" ) T arg = constructObject ( ( Class < T > ) subclass , mode , stack ) ; if ( arg != null ) { return arg ; } } catch ( InstantiationException e ) { LOG . debug ( "Instantiation exception : {}" , e ) ; } } } } catch ( ClassNotFoundException | IOException ignore ) { } finally { stack . pop ( ) ; } return cachedValue ; }
find a subclass to construct for abstract class .
