1

Imagine to have this class in some library, which gets added to another project as maven dependency:

class A {

    // What can I do to replace B.class ?
    @SomeAnnotation(B.class)
    private String someValue;

}

I would like to make the class literal B.class some kind of configurable for the mvn project that uses this as dependency. Do I need to do it via reflection capabilities, what are my possibilities here?

Jasper
  • 343
  • 1
  • 2
  • 9
  • 1
    I guess you cannot, even with reflections. Annotations are declarative – kret Sep 12 '18 at 15:15
  • https://stackoverflow.com/questions/14268981/modify-a-class-definitions-annotation-string-parameter-at-runtime – Kaushal28 Sep 12 '18 at 15:17
  • Where do you want to configure the value? – ernest_k Sep 12 '18 at 15:27
  • @ernest_k somewhere in the project that uses the containing dependency, that´s where I know which class literal would replace B.class – Jasper Sep 12 '18 at 15:39
  • @Jasper perhaps you could go up level and explain what problem you are trying to achieve there may be an alternative solution. – cyroxis Sep 12 '18 at 17:19

0 Answers0