newInstance(), how to call a constructor and pass parameters to it?
843798Feb 17 2003 — edited Feb 20 2003Hey all,
I am loading some classes dynamically. They all extend a specific "abstract" class that has a constructor with a number of parameters. I would like to be able to call this constructor and pass it the parameters dynamically. How is this done? I have seen the Method stuff, reflection, etc. But my code currently does something like:
MyClass mo = (MyClass)Class.forName(...).newInstance();
The MyClass may extend the "abstract" class I am talking about. In that abstract class the constructor takes on 3 parameters. So how could I call this at runtime to pass the 3 parameters?
Thanks.