That trick "works" in Java because, for compatibility reasons (Java didn't have generics originally), the generic type is erased by the compiler. Your example compiles to:
static List listOfAnything() { return (List) new ArrayList(); }
List stringList = listOfAnything();
List listOfInts() { return listOfAnything(); }
The generic type isn't monomorphised or even reified; within your method, you don't have access to the generic type T "passed" by the caller. If you need it, you have to pass it explicitly, as commonly used by deserialization libraries:
static <T> T deserialize(String input, Class<T> cls) { ... }
Which can be used like this:
MyStruct result = deserialize(input, MyStruct.class);
Note that the deserialization library has no way of knowing the type of the variable the caller is putting the result in, the caller had to pass it explicitly. This is because what the Java compiler actually generated from the code above was something like:
static Object deserialize(String input, Class cls) { ... }
MyStruct result = (MyStruct) deserialize(input, MyStruct.class);