Creating java class with annotated fields in runtime

Posted by Sarmun on Stack Overflow See other posts from Stack Overflow or by Sarmun
Published on 2010-05-21T22:26:24Z Indexed on 2010/05/21 22:30 UTC
Read the original article Hit count: 359

The problem is that I need to create in runtime a class like this:

public class Foo {
  @Bar int value0;
  @Bar int value1;
  @Bar int value2;
....
}

with number of fields being decided at runtime.

I was looking at Javassist, and there you can create a new class, and add fields to it, but I haven't found a way to annotate those fields.

© Stack Overflow or respective owner

Related posts about java

Related posts about code-generation