M
Mohun Biswas
Here's a small problem that's bugging me. I wrote a class for which I
originally provided a toString() method that, foolishly, did the wrong
thing. Now, as part of a refactoring exercise I want to fix it and find
and fix all the places the bad variant was used. I can't search
textually for "toString" because of the magic associated with that name,
such that it's invoked automatically when an instance is used in a
String context. I considered changing the method signature and letting
the compiler tell me where things go blooey, but of course the compiler
will simply find super.toString(), all the way back to Object if need
be. I'm thinking of creating a custom Exception and declaring my
toString to throw it so the compiler can tell me where it isn't caught
but that's ugly.
Is there a clean, deterministic way of solving this little corner case?
Thanks,
MB
originally provided a toString() method that, foolishly, did the wrong
thing. Now, as part of a refactoring exercise I want to fix it and find
and fix all the places the bad variant was used. I can't search
textually for "toString" because of the magic associated with that name,
such that it's invoked automatically when an instance is used in a
String context. I considered changing the method signature and letting
the compiler tell me where things go blooey, but of course the compiler
will simply find super.toString(), all the way back to Object if need
be. I'm thinking of creating a custom Exception and declaring my
toString to throw it so the compiler can tell me where it isn't caught
but that's ugly.
Is there a clean, deterministic way of solving this little corner case?
Thanks,
MB