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.UMC.FINALIZE

JD.UMC.FINALIZE shows that a method contains an explicit invocation of the finalize() method of an object.

Vulnerability and risk

Object finalizer methods are supposed to be executed once, and only by the JVM, so calling one explicitly is bad practice. Depending on the particular JVM and its method of implementation, the improper behavior may be because the object finalizer method was called twice.

Mitigation and prevention

It is better practice to avoid finalizers at all, and to create an explicit termination method with a different name. If absolutely necessary, a finalizer can call an object finalizer method as a "safety net".

Example 1

11     OutputStream st;
12     protected void finalize() throws Throwable {
13         if (st!=null) st.close();
14         super.finalize();
15     }
16 
17     void run() throws Throwable{
18         // ...
19         finalize();
20     }

JD.UMC.FINALIZE is reported for call on line 19: There is a call to a 'finalize()' method. This method is not intended to be called explicitly.