I am writing a program and as a requirement need to get all of the classes in a package, and need to return objects of them.
I have this code:
package object cards {
private val reflections: Reflections = new Reflections(
new ConfigurationBuilder()
.setUrls(ClasspathHelper.forPackage("me.mysterymystery.duelingfactions.apiv2.guiindependant.card.cards"))
.setScanners(new SubTypesScanner())
)
def getAllCards: Seq[Card] = reflections.getSubTypesOf(classOf[Card]).asScala.map(_.newInstance()).toSeq
...
}
But get java.lang.NoSuchMethodException: me.mysterymystery.duelingfactions.apiv2.guiindependant.card.MonsterCard.<init>()
Does anybody have any ideas as to why and how to fix it?
Aucun commentaire:
Enregistrer un commentaire