Dynamic class annotation Dynamic class annotation xml xml

Dynamic class annotation


No. Annotations are static class-level information and they can't be influenced by the values of instance fields (no, they can't influenced by the values of static fields either).


You can create new classes at runtime by loading in new bytecode, so in theory it should be possible (remember, the annotations are associated with the class, not the object). And you can use an API like Java Assist to help create them. There's an annotation package that you could look at.

It won't be easy.