[xwiki-devs] Component ReflectionUtils hidden fields
Hi XWiki-devs I noticed that org.xwiki.component.util.ReflectionUtils.getAllFields(Class<?>) <https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/util/ReflectionUtils.java#L59> does not return hidden fields <https://docs.oracle.com/javase/tutorial/java/IandI/hidevariables.html> of superclasses. These are actively filtered out by the implementation with the following comment: *Make sure that if the same field is declared in a class and its superclass only the field used in the class will be returned.* This implementation caused NPE's for us because the ComponentManager did not inject annotated hidden fields. Can somebody provide a good reason for this implementation? Thanks for the feedback and regards Marc
Hidden field is a known issue but the cause is not really ReflectionUtils, ReflectionUtils is just doing that to apply a limitation which is actually elsewhere: ComponentDependency only indicate the name of the field and not the class so it cannot really inject it in the right place. We need to decide if we want to extend ComponentDependency API. Historically we always tried to not add too many features in XWiki component manager with in mind the hope that we would move one day to some more standard component manager instead of our own (and this was a limitation of Plexus that we where using before starting to write our own component manager). On Fri, Sep 2, 2016 at 4:10 PM, Marc Sladek <marc.sladek@synventis.com> wrote:
Hi XWiki-devs
I noticed that org.xwiki.component.util.ReflectionUtils.getAllFields(Class<?>) <https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/util/ReflectionUtils.java#L59> does not return hidden fields <https://docs.oracle.com/javase/tutorial/java/IandI/hidevariables.html> of superclasses. These are actively filtered out by the implementation with the following comment:
*Make sure that if the same field is declared in a class and its superclass only the field used in the class will be returned.*
This implementation caused NPE's for us because the ComponentManager did not inject annotated hidden fields. Can somebody provide a good reason for this implementation?
Thanks for the feedback and regards Marc _______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (2)
-
Marc Sladek -
Thomas Mortagne