jeudi 29 juin 2017

Scala newInstance() an inner class nested in a trait

I'm using java reflection in order to dynamically instantiate all the classes sharing the same trait in the codebase. It's working currently if thoses classes do not belong to a super class.

So basically in order to instantiate Y :

class X {
  class Y {

  }
}

I have to use YConstructor.newInstance(XObject)

The problem arise when X is no more a class but a trait, and then there is no constructor that I can use for it, but I still need to feed an XObject to newInstance .. Tricky :(





Aucun commentaire:

Enregistrer un commentaire