Is there any way I can get Eclipse to highlight the use of the == operator to test String equality? I keep mistakenly using it instead of calling .equals().
I’d really like to make that into a warning and require an @SuppressWarnings annotation to remove it, in the yet-to-happen case that I actually want to compare strings for object equality.
Are there any tools can I use to help break this bad habit at edit-time?
Use a static analysis tool such as FindBugs, PMD, or CheckStyle.
There are Eclipse plugins for each, along with Ant tasks, Maven plugins, etc.
Each of these has rules relating to String equality (Findbugs rule, PMD rule, Checkstyle rule).