code: private static TypeElement resolveType(Elements elements, String className, StringBuilder sb,
        final int index) {
  
      // We assume '$' should be converted to '.'. So we search for classes with dots first.
      sb.setCharAt(index, '.');
      int nextIndex = nextDollar(className, sb, index + 1);
      TypeElement type = nextIndex == -1
          ? getTypeElement(elements, sb)
          : resolveType(elements, className, sb, nextIndex);
      if (type != null) {
        return type;
      }
  
      // if not found, change back to dollar and search.
      sb.setCharAt(index, '$');
      nextIndex = nextDollar(className, sb, index + 1);
      return nextIndex == -1
          ? getTypeElement(elements, sb)
          : resolveType(elements, className, sb, nextIndex);
    }
docs: Recursively explores the space of possible canonical names for a given binary class name.
  
  @param elements used to resolve a name into a {@link TypeElement}
  @param className binary class name
  @param sb the current permutation of canonical name to attempt to resolve
  @param index the index of a {@code '$'} which may be changed to {@code '.'} in a canonical name