mercredi 10 février 2021

Quarkus removes unused annotations at compite/build time, which we need at runtime

My project is based on Quarkus and the use of Reflections helps me to search for classes which implement specific annotation.

Reflections reflections = new Reflections(path);
Set<Class<?>> customAnnotationClassSet = reflections.getTypesAnnotatedWith(CustomAnnotation.class);

The resulting set is correct, it is filled with classes, but I cannot apply following method over the classes, the result will be null.

cls.getDeclaredAnnotations() --> null

Instead, when I use a specific class, I can access its declared annotations.

CustomClass.class.getDeclaredAnnotations() --> getting annotations

It looks like Quarkus removes unused annotations at compite/build time, which we need at runtime.

Is there a solution for this problem?





Aucun commentaire:

Enregistrer un commentaire