java - How to inspect runtime annotations with javassist -
java - How to inspect runtime annotations with javassist -
when attempting inspect code @ runtime using javassist need @ annotations. simple example:
classpool pool = classpool.getdefault(); ctclass clazz = pool.getctclass("org.junit.test"); boolean found = false; (object annotation : clazz.getavailableannotations()) { if ("java.lang.annotation.target".equals(annotation.getclass().getname())) { found = true; } }
the problem code never sets found = true
. annotation classes returned are:
com.sun.proxy.$proxy8 com.sun.proxy.$proxy9
any thought how actual annotations rather proxies? or how 1 actual annotation proxy?
annotation objects not direct instances of annotation type, instances of (proxy in case) object implements annotation interface.
try if (annotation instanceof java.lang.annotation.target)
java javassist
Comments
Post a Comment