TypeUtil { public static Class<?> getRawClass(Type type) { if (type instanceof Class) { return (Class<?>) type; } if (type instanceof ParameterizedType) { return (Class<?>) ((ParameterizedType) type).getRawType(); } if (type instanceof TypeVariable) { Type[] bounds = ((TypeVariable) type).getBounds(); if (null != bounds && 0 < bounds.length) { return getRawClass(bounds[0]); } } return Object.class; } private  TypeUtil(); static Class<?> getRawClass(Type type); static Class<?> getFirstTypeArgument(Type type);  }
@Test public void getRawClass() throws Exception { assertThat(TypeUtil.getRawClass(getClass().getField("boolField").getGenericType())).isEqualTo(boolean.class); assertThat(TypeUtil.getRawClass(getClass().getField("stringListListField").getGenericType())).isEqualTo(List.class); assertThat(TypeUtil.getRawClass(getClass().getField("stringListListField").getGenericType())).isEqualTo(List.class); assertThat(TypeUtil.getRawClass(getClass().getMethod("get", int.class).getGenericReturnType())).isEqualTo(Object.class); }