Java Interface Reflection Alternatives

Posted by Phaedrus on Stack Overflow See other posts from Stack Overflow or by Phaedrus
Published on 2011-02-04T15:17:57Z Indexed on 2011/02/04 15:26 UTC
Read the original article Hit count: 186

Filed under:
|
|
|

I am developing an application that makes use of the Java Interface as more than a Java interface, i.e., During runtime, the user should be able to list the available methods within the interface class, which may be anything:

private Class<? extends BaseInterface> interfaceClass.

At runtime, I would like to enum the available methods, and then based on what the user chooses, invoke some method.

My question is: Does the Java "Interface" architecture provide any method for me to peek and invoke methods without using the Reflection API?

I wish there were something like this (Maybe there is):

private Interface<? extends BaseInterface> interfaceAPI;

public void someMethod(){
 interfaceAPI.listMethods();
 interfaceAPI.getAnnotations();
}

Maybe there is some way to use Type Generics to accomplish what I want?

Thanks,

Phaedrus

© Stack Overflow or respective owner

Related posts about java

Related posts about generics