Dynamic instances of unknown-name classes that implements a known interface
<p>I'm absolutely stuck - I have a java app that needs to allow a java-based plugin to "inject" a custom class(es) for handling custom db record types they've registered with my app's api.</p>

<p>The plugin must define a class that implements our <code>Handler</code> interface. We read data from the database and if it belongs to that custom class, I need to be able to create an instance of that class and give it the data.</p>

<p>I just can't find a good/safe way to do that. </p>

<p>Using <code>Class.forName</code> feels too unsafe if they could pass in <code>whatever.package.they.wanted</code></p>

<p>Is there a way they can pass the <code>.class</code>? I tried but it doesn't appear to work if I refer to the interface instead, <code>Class&lt;Handler&gt;</code> - since I'll never know the class names they define.</p>

<p>I don't want them to just pass me a single instance, because we need a new instance for each database record that belongs to them. It could be one, it could be a dozen. I need to be able to make the instances (or at least call a class that gives me an instance) when I need it.</p>
