So how can I do the following in Java?
List strings = new ArrayList();
JAXBElement> jax = new JAXBElement>(new QName("strings"), List.class, strings);
The issue specifically occurs at List.class and the error returned is:
Multiple markers at this line
- List cannot be resolved to a variable
- String cannot be resolved to a variable
- Syntax error on token ">", void expected after this token
解决方案
You can't.
The closest approximation to what you want is to use (Class>) List.class.
This is because there is no List.class, because at runtime, List, List, List, and List are all the same in Java. This is deliberately done for a whole bunch o' reasons, and it's called type erasure.