开发者

How to find which classes implement a particular interface in Eclipse?

I have an application as JAR file with many dependencies. For some reason I need to decompile one of the libraries and open it up with Eclipse. For a given interface in the project, is there a w开发者_运维技巧ay to find the class(s) that implements it? It may be the case that the interface was implemented in other library that I didn't decompile yet. Is it possible to do this for this kind of classes?


Right-click on the interface, and choose "Open type hierarchy". Then click on "Show the subtype hierarchy".


Try Ctrl+T after selecting the classname; should work in Java Perspective.


You can "Show Type Hierarchy" on the item (Right Click to choose this option or press F4 when the item is highlighted)*.

However, this will list only items in those projects that are referred ("dependent"). Not in others.

So if you have decompiled a jar, and there is another jar that you have not decompiled, then the implementations (of the interface) in that jar will not be listed.

Also, say you have decompiled a jar as a project and there is another project that is referring to the jar, and not the decompiled project, implementations in that will also not be listed.

So you will have to decompile all jars and add them as projects (and add references via "Java Build Path") to make sure all the implementations in the jars of your choice are listed.

* Quick type Hierarchy, ctrl + T will show a similar structure in a tooltip/autocomplete kind of panel. But the complete type hierarchy is more useful for the type of analysis you are intending to do.


There is radio-button "Implementors" in Java Search.


Or right-click and select Quick Type Hierarchy for a pulldown menu of extending interfaces and implementing classes.


Ctrl + H (Search Option) Open Java Search perspective and, enter the interface name, click Implementors radio button and you will find which classes implement a particular interface. Same as answer from stackexchanger above


Select the class name, then 'F4' in Eclipse (Windows environment)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜