Explicit Call to Finalize() |
Weakness ID: 586 (Weakness Variant) | Status: Draft |
Description Summary
The software makes an explicit call to the finalize() method from outside the finalizer.
Extended Description
While the Java Language Specification allows an object's finalize() method to be called from outside the finalizer, doing so is usually a bad idea. For example, calling finalize() explicitly means that finalize() will be called more than once: the first time will be the explicit call and the last time will be the call that is made after the object is garbage collected.
Example 1
The following code fragment calls finalize() explicitly:
(Bad Code)
Example Language: Java
// time to clean up
widget.finalize();
Do not make explicit calls to finalize(). Use static analysis tools to spot such instances. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 227 | Failure to Fulfill API Contract ('API Abuse') | Research Concepts (primary)1000 |
ChildOf | ![]() | 398 | Indicator of Poor Code Quality | Development Concepts (primary)699 |
PeerOf | ![]() | 675 | Duplicate Operations on Resource | Research Concepts1000 |
Modifications | ||||
---|---|---|---|---|
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Name, Potential Mitigations, Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Relationships, Other Notes | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples | ||||
2009-10-29 | CWE Content Team | MITRE | Internal | |
updated Description, Other Notes | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-09-09 | Explicit Call to Finalize | |||