[SOLVED] Instantiating a particular class constructor using reflection

Actually that’s the tricky part to instantiate an inner class! :mage:

B/c even before instantiating an inner class, an instance of its enclosing class needs to exist 1st. :open_mouth:

In our case, the enclosing class instance is the sketch itself, a subclass of PApplet. :nerd_face:

1 Like

There’s a small bug in your posterity solution: :sweat:

B/c variable innerCls isn’t initialized right way, that’ll never happen if the try {} fails! :fearful:

You can replace System.err.println(ex); w/ throw new RuntimeException(ex); inside the catch () {} block in order to override that. :bulb:

1 Like

Posterity Code amended…

1 Like