Annotations
Hi All,
I'm having a little problem with using annotations (which seem like a great feature).
I wrote the annotation called DeviceParameter and added it to some methods of a class. However, when I call getDeclaredAnnotations ot getAnnotation(DeviceParameter.class) on instances of those methods, I get back an empty array and null, respectively.
Here is my annotation:
Here's a method that uses it:
Here is how I try to get back the annotation parameters:
What could be wrong? I don't see any relevant compiler warnings. Do I need to turn on some compiler option?
Thanks in advance.
I'm having a little problem with using annotations (which seem like a great feature).
I wrote the annotation called DeviceParameter and added it to some methods of a class. However, when I call getDeclaredAnnotations ot getAnnotation(DeviceParameter.class) on instances of those methods, I get back an empty array and null, respectively.
Here is my annotation:
public @interface DeviceParameter {
String units();
String name();
String description();
boolean isReference() default false;
}Here's a method that uses it:
@DeviceParameter(description="gate sweep frequency", name="fSweep", units="Hz", isReference=true)
public Number getSweepFrequency() {
return adm.getGateSweepFrequencyNumber();
}Here is how I try to get back the annotation parameters:
for (Method m : calc.getClass().getMethods()) {
logger.info("processing method " + m); //this lists the method
logger.info("declared annotations: " + Arrays.asList(m.getDeclaredAnnotations() )); //empty
DeviceParameter deviceParameter = m.getAnnotation(DeviceParameter.class); //null
.......What could be wrong? I don't see any relevant compiler warnings. Do I need to turn on some compiler option?
Thanks in advance.
