I created a lot of annotations in my life and now come to the strange case that I need this annotation, and I don’t think that it is supported by Java at all. Please tell me that I am right or wrong.
Here is my annotation:
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface DetailsField { public String name(); }
And now the question! I would like the default value of the name () function to be the name of the field in which I posted the annotation.
I don’t know exactly how the class handler handles annotations, I’m sure that this is not implemented in the standard class loader, but can it possibly be achieved using the bytecode toolkit during class loading by the user class loader? (I'm sure if this is the only solution, I would find a way, just curious)
Any ideas? Or do I really want?
Roman source share