jeudi 28 juin 2018

java class.getAnnotation(Class?> class) returns null

I have written an annotation:

@Documented
@Retention(RUNTIME)
@Target(TYPE)
/**
 * @author christian
 *
 */
public @interface HeraklesObject {

}

I use it in an osgi environment (eclipse oxygen with tycho) in a bundle. In another bundle (a test fragment to be specific) i check classes from the first bundle for this annotation, using:

class.getAnnotation(HeraklesObject.class)

I am sure, that the queried class has this annotation, but I get always null result.

The retention policy seems right to me, but I am not sure if a class loader issue is present and I don't know how I check this. Or do you see another cause? Thanks Christian





Aucun commentaire:

Enregistrer un commentaire