Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find type specific references to equals() in the workspace in Eclipse?

I've got a class which overrides equals() and I want to see where this equals method is being used in the workspace. Using Eclipse, I generally do Ctrl-Shift-g which finds all references in the workspace. Unfortunately, for equals(), its pulling back every single reference of equals in my workspace from any type, not just the one where I've overridden it and its impossible to figure out which of the many results is pertinent to my search. Is what I want to do possible?

EDIT: To clarify. I have a class A which overrides the equals method. I have a class B (and others) which use class A but do not extend it. I want to find which classes in my workspace use Class A's equals method regardless of whether or not they belong to Class A's hierarchy such as Class B.

like image 760
Chris Knight Avatar asked Oct 28 '10 10:10

Chris Knight


People also ask

How do you find where a class is called in eclipse?

In Eclipse IDE, you can type CTRL + SHIFT + T in Windows or *nix or Command + SHIFT + T in Mac OSX to prompt an Open Type dialog box to find details about a specified Java class.


1 Answers

Let your equals implementation temporarily throw the class Throwable: equals(Object obj) throws Throwable.

Of course this will give you a compile error on your equals implementation because it is not compatible with Objects.equals(), however you will also get a compile error in all classes which are using your equals method (at least all classes which do not handle/throw Throwable themselves):

Unhandled exception type Throwable

like image 172
Dominic Avatar answered Oct 20 '22 15:10

Dominic