Take a look at ```Reflections.tryToCreateNewInstance()```, it does very similar thing.