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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With