How can I define a parameterized List field using Javassist? I have tried the following code which does not complain with an unparameterized List class, but causes a CannotCompileException when given a parameter.
ClassPool pool = ClassPool.getDefault();
pool.importPackage("java.util.List");
CtClass cc = pool.makeClass("Test");
CtField f = CtField.make("public List<String> p;", cc);
// throws javassist.CannotCompileException: [source error] syntax error near "lic List<String> p;"
I'd guess the language compliance level of the compiler javassist is using internally is set to Java 1.4, which would explain why it doesn't understand generics (they were introduced in 1.4)