Calling a constructor through reflection in scala 2.10
问题 What's the best practice for calling a constructor of a class in scala 2.10 (M4+) ? 回答1: Answering my own question: Calling the constructor is different than invoking a method. Here's the right way to do it in scala 2.10 import reflect.runtime.universe._ import reflect.runtime.currentMirror val typ = typeOf[Range] val constructor = typ.members.find(_.kind == "constructor").get.asMethodSymbol currentMirror reflectClass typ.typeSymbol.asClassSymbol reflectConstructor constructor apply (1,10,1)