Home > Mobile >  Kotlin, child how to use reflection to obtain a constructor?
Kotlin, child how to use reflection to obtain a constructor?

Time:12-05



As shown in the above, the subclass by reflection gain parameter list, the parameters in the parameter list only subclasses, and the incoming object contains the parameters of the parent class, eventually led to the parameters and construction methods don't match, an exception is thrown,
Problems of code is used to fastjson throws an exception in JSON. The toJavaObject (JSON JSON, Class Clazz), of which clazz is subclasses, json is a subclass object,
Could you tell me how to write a constructor can meet here parameters requirements?