The uh, rather tactless, posting above was correct.
Here is a way to show it. Just create the two files below and run the main method of TestMyModifiers.
---------Begin contents of XMLSaveable.java-------------------
import java.lang.annotation.*;
@Target(ElementType.FIELD)
@Retention(value=RetentionPolicy.RUNTIME)
public @interface XMLSaveable {
}
---------------------End Contents------------------------------
--------------- Begin contents of TestMyModifiers.java ----------
import java.lang.reflect.*;
public class TestMyModifiers{
public @XMLSaveable int myStuff = 0;
public int yourStuff = 0;
public static void main(
String args[]){
TestMyModifiers tmm = new TestMyModifiers();
tmm.myStuff = 1;
Class c = tmm.getClass();
for (Field f : c.getFields()) {
if (f.isAnnotationPresent(XMLSaveable.class)) {
System.out.println(f.getName() + " is XMLSaveable");
} else {
System.out.println(f.getName() + " is not XMLSaveable");
}
}
}
}
-------------------End Contents-------------------------
It gives the output:
myStuff is XMLSaveable
yourStuff is not XMLSaveable
And this truly does rock.
Thanks to all of the people who helped me with this!
[ January 20, 2006: Message edited by: Skip Cole ]