Menu

#30 ClassEmitter does not preserve field annotations

open
nobody
None
5
2009-05-26
2009-05-26
Erick
No

When using TransformingClassGenerator to transform a class (for example InterceptFieldTransformer), class and method field annotations are preserved, but field level annotations are lost. This happens since the visitField method in net.sf.cglib.core.ClassEmitter does not return a FieldVisitor. There is a TODO listed on line 264 of that file that obviously has not been done. Since all the field declaration tracking code is private/package private, it's impossible to work around by overriding. I'm using a *very* dirty hack to circumvent this issue since I need field level annotations on my transformed classes.

Discussion

  • Emmanuel Bernard

    BTW, I am releasing the patch under the ASL 2.0 license, just like CGLIB's license.