Possible duplicate of: Alternatives to java.lang.reflect.Proxy for creating proxies of abstract classes (rather than interfaces)
Suppose I have this class:
public class MyClass {
public void doStuff() {
//stuff
}
public int getSomeIntStuff() {
//int stuff
return intStuff;
}
private void helperStuff() {
//helper Stuff
}
}
Is there a way to get an interface class (dynamically generated?) that represents the public interface of this class?
The public interface of this class (if it would have been written) would look:
public interface MyClassInterface {
void doStuff();
int getSomeIntStuff();
}
but this has to be somehow dynamically generated and I would expect something like this:
Class<?> interfaceClass = MyClass.class.getEncompasingInterface();
What I try to achieve is to create a Java Proxy based on some existing classes not on existing interfaces, and the Proxy.newProxyInstance(ClassLoader, Class<?>[], InvocationHandler)
method expects as a second argument strictly a list of Java interfaces not classes.