SDA SE WikiSoftware Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
This class defines an equals() method, that doesn't override the normal equals(Object) method defined in the base java.lang.Object class. The class should probably define a boolean equals(Object) method. – 2013-10-13
Every method named equals must have the signature public boolean equals(Object) in order to override the equals method from java.lang.Object. So, it is considered as a bug if you create a method named equals, having
<code Java> private void equals(){
} </Code>
<code Java> public boolean equals(Object… o){
return false;
} </Code>
<code Java> public boolean equals(Object o, int i){
return false;
} </Code>
<code Java> public boolean equals(int i){
return false;
} </Code>
An idea to “fix” the problem is by renaming the methods so they can be distinguished from the actual equals() method.
<code Java>
private void myEquals(){
}
public boolean myEquals(Object o, int i){
return false;
}
</Code>
| Benchmark project | Precision | Recall | ||||
|---|---|---|---|---|---|---|
| FB | JT | Delta | FB | JT | Delta | |
| Project … | …% | …% | …% | …% | …% | …% |
| Project … | …% | …% | …% | …% | …% | …% |
FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBugs
Apache Tomcat
FindBug→Finds invocations and not the actual methods (2) and does not even follow control flow (our own test case)
JT→ Finds the actual declarations of the methods (20)