JD.INF.AREC
JD.INF.AREC occurs when the method calls itself without any prior checks.
Vulnerability and risk
If this method is called, it will call itself again and again, and then the program stack will overflow and the JVM will throw a StackOverflowError. Obviously this is not what the programmer intended.
Mitigation and prevention
JD.INF.AREC has three possible causes.
- There is a misspelled instance object. For example, instead of "super.equals(o)", the programmer typed "this.equals(o)" Fix the spelling of the instance object.
- The argument of the method is not cast for a specific type. For example, it should be this.equals((MyType)o). Cast the argument to a specific type.
- A condition for terminating the recursion is missing. Add a condition that will stop recursion.
Example 1
Copy
/**
* Implementation required by the interface.
* @param o - object to compare
* @return true, if equal.
*/
public boolean equals(Object o) {
return this.equals(o);
}
JD.INF.AREC is reported for call on line 16: Apparent infinite recursion by calling 'equals(java.lang.Object)' from itself