Creating anonymous dynamic runtime instances
<p>How can I create implementations of an interface dynamically at runtime in java?</p>

<p>I have a factory that will read the annotations on class Foo and create an instance of class Bar. For this factory to be type safe, I'd like my client factories to be interfaces with a factory method that takes type Foo and returns type Bar. I then want my factory to implement this factory method at runtime.</p>

<p>All of this is because the factory code would be redundant and hard to maintain. If generated at runtime, it would always be current.</p>

<p>Example:</p>

<pre><code>public class Foo{
    private String name;

    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name = name;
    }
}

public class Bar{
    private String personName;

    public String getPersonName(){
        return personName;
    }

    public void setPersonName(String personName){
        this.personName= personName;
    }
}

public interface BarFactory{
    Bar create(Foo foo);
}
</code></pre>

<p>Is there a way to do this?</p>
