Type (@NotNull TypeVariable<?> variable, @NotNull Class<?> aClass) { Type type; Class<?> current = aClass; while ((type = resolveVariable(variable, current, false)) == null) { current = current.getSuperclass(); if (current == null) { return null; } } if (type instanceof TypeVariable) { return resolveVariableInHierarchy((TypeVariable<?>)type, aClass); } return type; }