While developing a ant - task to autogenerate some gui - code for a project using annotations as I prefer a declarative approach I am using the java.net.URLClassLoader
to dynamically add
the classes to my class path.
When scanning the classes for class - level - annotations none of them is found though
they exists.
e.g.
@AutoGenerateGUI
class LoginBean
Has anyone else experienced this problem and can provide a solution?
(Subclassing the URLClassLoader to make the call to loadClass internally be treated as loadClass(Class clazz, true) didn't work neither)
Thanks to https://stackoverflow.com/users/1103872/marko-topolnik In Addition: Retrieving the annotations of the dynamically loaded classes always returned com.sun.proxy.$Proxy[x], so to get to the original annotation type I had to use the construct URLClassLoader loads Annotation as com.sun.$Proxy$27 iterating over the interfaces the proxy object implements. Though this should not be necessary, indeed other solutions e.g. using instanceof failed.