结构: Simple
Abstraction: Variant
状态: Draft
被利用可能性: unkown
The software makes an explicit call to the finalize() method from outside the finalizer.
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.
cwe_Nature: ChildOf cwe_CWE_ID: 1076 cwe_View_ID: 1000 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 1076 cwe_View_ID: 699 cwe_Ordinal: Primary
Language: {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}
范围 | 影响 | 注释 |
---|---|---|
['Integrity', 'Other'] | ['Unexpected State', 'Quality Degradation'] |
策略:
Do not make explicit calls to finalize(). Use static analysis tools to spot such instances.
The following code fragment calls finalize() explicitly:
bad Java
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
The CERT Oracle Secure Coding Standard for Java (2011) | MET12-J | Do not use finalizers | |
Software Fault Patterns | SFP3 | Use of an improper API |