I'd like to use reflection to get names (in addition to types) of a class method parameters in runtime. This is only possible when my class is compiled with -parameters javac option. There are obviously good reasons not to have this option enabled by default for all classes. To avoid complications of separate compilation of few classes from a library (by a user), I'm wondering if it's possible to implement an annotation processor where I could control the compiler options, at the class level? Are there any hooks, javac runtime API etc?
Example implementation:
// annotation processor for CompileOptionParameters annotation:
// enable "-parameters" when compiling MyClass
// library class
public class Base {
Base() {
// use reflection to get "message" and "value" from the derived class(es) constructor(s)
}
}
// user class
@CompileOptionParameters
public class MyClass extends Base {
MyClass(String message, int value) {
super() ;
}
}