This does not compile, any suggestion appreciated.
... List list = getList(); return (List) list;
Compil
You can create a new List and add the elements to it:
For example:
List a = getListOfA(); List newList = new ArrayList<>(); newList.addAll(a);