### Question:
GenericUtils { public static <T> Class genericClass(Class<T> clazz) { Type genericSuperclass = clazz.getGenericSuperclass(); if (genericSuperclass == null) { throw new RuntimeException(Info.get(GenericUtils.class, R.NO_GENERIC_SUPER_CLASS)); } if (!(genericSuperclass instanceof ParameterizedType)) { genericSuperclass = ((Class) genericSuperclass).getGenericSuperclass(); if (genericSuperclass == null) { throw new RuntimeException( Info.get(GenericUtils.class, R.NO_GENERIC_CLASS_TO_PARENT1, clazz.getGenericSuperclass().getTypeName())); } if (!(genericSuperclass instanceof ParameterizedType)) { throw new RuntimeException( Info.get(GenericUtils.class, R.NO_GENERIC_CLASS_TO_PARENT1, clazz.getGenericSuperclass().getTypeName())); } } Class<T> genericClass = (Class<T>) ((ParameterizedType) genericSuperclass).getActualTypeArguments()[0]; return genericClass; }  static Class<T> ancestorGenericClass(Class<T> clazz); static Class<T> parentGenericClass(Class<T> clazz); static ParameterizedType firstParameterizedType(Class<T> clazz); static Class genericClass(Class<T> clazz);  }### Answer:
@Test public void testParentsParent() { Assertions.assertSame(LinkedList.class, GenericUtils.genericClass(CCC.class)); }
@Test public void testParent() { Assertions.assertSame(LinkedList.class, GenericUtils.genericClass(BBB.class)); }
@Test public void testParentNoGenericType() { Assertions.assertThrows(RuntimeException.class, () -> GenericUtils.genericClass(AAA.class)); }
@Test public void testJavaObject() { Assertions.assertThrows(RuntimeException.class, () -> GenericUtils.genericClass(Object.class)); }
@Test public void testAncestor() { Assertions.assertThrows(RuntimeException.class, () -> GenericUtils.genericClass(DDD.class)); }