in src/main/java/org/apache/sling/junit/jupiter/osgi/impl/ReflectionHelper.java [44:68]
private static void determineTypeArguments(Class<?> clazz, Map<TypeVariable<?>, Type> typeVariableTypeMap) {
final Type genericSuperclass = clazz.getGenericSuperclass();
if (genericSuperclass instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
typeVariableTypeMap.putAll(TypeUtils.determineTypeArguments(clazz, parameterizedType));
final Type rawType = parameterizedType.getRawType();
if (!(rawType instanceof Class<?>)) {
throw new UnsupportedOperationException("Expected Class#getGenericSuperclass() to return an object of type Class<?>");
}
determineTypeArguments((Class<?>) rawType, typeVariableTypeMap);
} else if (genericSuperclass instanceof Class<?>) {
determineTypeArguments((Class<?>) genericSuperclass, typeVariableTypeMap);
} else if (genericSuperclass == null) {
final Type[] genericInterfaces = clazz.getGenericInterfaces();
for (Type genericInterface : genericInterfaces) {
if (genericInterface instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) genericInterface;
typeVariableTypeMap.putAll(TypeUtils.determineTypeArguments(clazz, parameterizedType));
}
}
} else {
throw new UnsupportedOperationException("Expected Class#getGenericSuperclass() to return null or an object of type Class<?> or ParameterizedType");
}
}