This does not compile, any suggestion appreciated.
... List list = getList(); return (List) list;
Compil
Depending on your other code the best answer may vary. Try:
List extends Object> list = getList(); return (List) list;
or
List list = getList(); return (List) list;
But have in mind it is not recommended to do such unchecked casts.