Why would specifying "fm.config.sites" work & "fm.config.sites.networks" not work for base class?

17 views
Skip to first unread message

Eric Peters

unread,
Mar 21, 2013, 2:25:40 PM3/21/13
to google-code...@googlegroups.com
Weird, not sure if its a bug or what, but here's the behavior I'm seeing

scala> val ref = new Reflections("fm.config.sites.networks")
ref: org.reflections.Reflections = org.reflections.Reflections@4480e1f8

scala> ref.getSubTypesOf(classOf[fm.model.Site])
res1: java.util.Set[Class[_ <: fm.model.Site]] = []

(doesn't work - empty set)

vs

scala> val ref = new Reflections("fm.config.sites")
ref: org.reflections.Reflections = org.reflections.Reflections@6e3409ba

scala> ref.getSubTypesOf(classOf[fm.model.Site])
res2: java.util.Set[Class[_ <: fm.model.Site]] = [class fm.config.sites.networks.yearone, class fm.config.sites.networks.tirerack, class fm.config.sites.networks.A18G8GVWHHIMY9, class fm.config.sites.networks.pdmautoparts, class fm.config.sites.networks.autohausaz, class fm.config.sites.networks.oereplacement, class fm.config.sites.networks.A3S8PGWS6GY5FN, class fm.config.sites.networks.andysautosport, class fm.config.sites.networks.primechoiceautoparts, class fm.config.sites.networks.empirecovers, class fm.config.sites.networks.A39H7TJSTSYZEU, class fm.config.sites.networks.autoparts123, class fm.config.sites.networks.A1J7OTSURZAVWI, class fm.config.sites.networks.superatv, class fm.config.sites.networks.A2LQ036XGSZPVD, class fm.config.sites.networks.autopartsexpress, class fm.config.s...

Works fine.

As you can see the classes are actually in the package fm.config.sites.networks, so shouldn't specifying the base class fm.config.sites.networks work?

Thanks,

Eric

mamo

unread,
Mar 21, 2013, 6:34:05 PM3/21/13
to google-code...@googlegroups.com
new Reflections("fm.config.sites.networks") is actually equivalent to new Reflections(ClasspathHelper.forPackage("fm.config.sites.networks"), new FilterBuilder().include("fm.config.sites.networks"))
so the path is treated as base package.
what you probably need is new Reflections(ClasspathHelper.forPackage("fm.config.sites.networks"))

Eric Peters

unread,
Mar 22, 2013, 12:08:50 PM3/22/13
to google-code...@googlegroups.com
Very interesting that does appear to work

The javadocs might need to be updated to describe when you pass in the "string" as an Object into the constructor.  I didn't see any reference to FIlterBuilder: http://reflections.googlecode.com/svn/trunk/reflections/javadoc/apidocs/org/reflections/Reflections.html

What exactly is FilterBuilder, and what is the .include() doing there that makes it behave differently than calling "new Reflections(ClasspathHelper.forPackage("fm.config.sites.networks"))" directly?

Thanks,

Eric
Reply all
Reply to author
Forward
0 new messages