ReflectionHelper { public static Class<?> getConcreteTypeOfGenericClassExtension( Class<?> classToExamine, int parameterIndex) { Type genericSuperclassType = classToExamine.getGenericSuperclass(); if (genericSuperclassType instanceof ParameterizedType) { Type[] actualTypes = ((ParameterizedType) genericSuperclassType).getActualTypeArguments(); if (actualTypes.length >= parameterIndex) { return (Class) actualTypes[parameterIndex]; } } return null; } private  ReflectionHelper(); static Class<?> getConcreteTypeOfGenericInterfaceImplementation(
            Object instanceToExamine,
            Class<?> implementedInterfaceClass,
            int parameterIndex); static Class<?> getConcreteTypeOfGenericClassExtension(
            Class<?> classToExamine,
            int parameterIndex); static Object instanceFromClassName(String className);  }
@Test void genericClassExtension() { assertThat( getConcreteTypeOfGenericClassExtension(AbstractClassImpl.class, 0), is(Double.class)); assertThat( getConcreteTypeOfGenericClassExtension(new AbstractClassImpl().getClass(), 0), is(Double.class)); }