Tuesday, October 30, 2012

Eclipse: Show all instances of implementors of selected Java Interface

UPDATE: Added support for showing instances of classes that have specified Annotations (e.g. @Resource) on them. Added support for not showing instances for a class if the number of instances is 0.

In this blog entry I talked about extension to Eclipse Java debugger to show all instances of selected Java Class in the Expressions view. Someone requested the support for showing all instances of objects that implement selected Java Interface. I have implemented that feature now. To fully understand the context see the original blog entry first. Then see the screenshots below:

You can install the plug-in from the plug-in's update site:




Mitzipi said...

A must-have plugin for any serious debugging session - it works flawlessly! Thank you so much for spending your time on this useful enhancement!

Now a next feature came to my mind: "Find all instances of all classes annotated with some selectable annotation":

I often have to debug Spring Framework applications. Such an application may have classes that don't extend any specific class or implement any specific interface. Instead, such an application consists of classes that are annotated by @Controller, @Service, @Repository. The Spring container picks up these classes during component scanning and instantiates them.

It'd be nifty to find all instances of those annotated classes, so the user knows which classes got instantiated.

Sandip Chitale said...

@Mitzipi I have implemented what you asked for. Try the version 1.0.16 and let me know if it works for you.

Mitzipi said...

This is too good to be true! I just gave your updated version a try and was able to find all objects whose classes are annotated with some Java annotation. Now I can finally easily find all the @Something-annotated objects registered by Spring's container behind the scenes.
Sandip, thank you so much for saving lots of time elsewise lost in "object hunting"!

... I was bold and posted an enhancement request to Eclipse JDT's bugtracker (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=393490 ): maybe there is somehow the possibility to contribute your plugin to the JDT debugger core.