I want to write a simple annotation like “@interface MyClassAnnotation” and “@interface MyMethodAnnotation” that targets Classes and Methods! but the main problem is that on main function i need to list all Class and Method instances on all JVM having that annotations! and I do not want to use any extra libraries, just pure built-in java functions.
Can anyone give me a good snippet for it?
I want to write a simple annotation like @interface MyClassAnnotation and @interface MyMethodAnnotation that
Share
You can determine whether your annotation is present on a particular class or method using the
getAnnotationelement, which is implemented by bothClassandjava.lang.reflect.Method.The real question is, which classes and methods do you want to test this on? “All of them” is a bit hard to define. There doesn’t seem to be a way to enumerate all of the classes that have been loaded by the JVM.