Java Reflection: Create an implementing class
interface, java, reflection
Solution
Creating something which pretends to implement an interface on the fly actually isn't too hard. You can use `java.lang.reflect.Proxy` after implementing `InvocationHandler` to handle any method calls.
Of course, you could actually generate a real class with a library like BCEL.
If this is for test purposes, you should look at mocking frameworks like jMock and EasyMock.
Problem
``` Class someInterface = Class.fromName("some.package.SomeInterface"); ``` How do I now create a new class that implements `someInterface`? I need to create a new class, and pass it to a function that needs a `SomeInterface` as an argument.