This is a question derived from Build A Generic Tree With Inheritance . I open this one as a separate questi
Check out TypeTools for this. Example:
List stringList = new ArrayList() {}; Class> stringType = TypeResolver.resolveRawArgument(List.class, stringList.getClass()); assert stringType == String.class;