Java接口反射替代方案

Pha*_*rus 2 java generics reflection interface

我开发一个应用程序,它利用了Java接口的作为比Java接口,即在运行时,用户应该能够列出接口类中可用的方法,它可以是任何东西:

private Class<? extends BaseInterface> interfaceClass.
Run Code Online (Sandbox Code Playgroud)

在运行时,我想枚举可用的方法,然后根据用户选择的方法,调用一些方法.

我的问题是:Java"接口"架构是否为我提供了任何方法,可以在不使用Reflection API的情况下查看和调用方法?

我希望有类似的东西(也许有):

private Interface<? extends BaseInterface> interfaceAPI;

public void someMethod(){
 interfaceAPI.listMethods();
 interfaceAPI.getAnnotations();
}
Run Code Online (Sandbox Code Playgroud)

也许有一些方法可以使用Type Generics来完成我想要的东西?

谢谢,

费德鲁斯

And*_*ite 5

这正是Reflection所构建的.