Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

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

10    /**
11     * Implementation required by the interface.
12     * @param o - object to compare
13     * @return true, if equal.
14     */
15    public boolean equals(Object o) {
16      return this.equals(o);
17    }

JD.INF.AREC is reported for call on line 16: Apparent infinite recursion by calling 'equals(java.lang.Object)' from itself