I found that I can't use a reference to a Class with "class".
For example:
CtClass clazz = pool.get("java.lang.Class");
CtMethod m = new CtMethod(clazz, "getClazz", null, myClass);
m.setBody("{return java.lang.String.class; }");
will throw an exception:
Caused by: javassist.CannotCompileException: [source error] missing member name
at javassist.CtBehavior.setBody(CtBehavior.java:163)
at javassist.CtMethod.setBody(CtMethod.java:311)
Is it a known issue?
Thanks,
alex
Unfortunately, it is a specification.
Use Class#forName.