I'm trying to find a means to obtain the value of public static final fields in a class.
For example, given:
I'm determining the value of the class constant ABC.
So far, I've come up with:
However, that method requires that an instance of the declaring class be instantiated, therefore requiring that the declaring class have a no-args constructor. (This would be moot if I had an instance of the declaring class lying around, but I do not.)
Given that the field in question is public, static and final, it occurs to me that the value should be able to be determined without the need to instatiate an instance of the class, but I haven't been able to discern a means to do that.
Anyone know if this is possible without resorting to uber-hackery?
Extra credit: what if the field is declared in an interface?
For example, given:
I'm determining the value of the class constant ABC.
So far, I've come up with:
However, that method requires that an instance of the declaring class be instantiated, therefore requiring that the declaring class have a no-args constructor. (This would be moot if I had an instance of the declaring class lying around, but I do not.)
Given that the field in question is public, static and final, it occurs to me that the value should be able to be determined without the need to instatiate an instance of the class, but I haven't been able to discern a means to do that.
Anyone know if this is possible without resorting to uber-hackery?
Extra credit: what if the field is declared in an interface?