Overriding the ``++Object.finalize()++`` method must be done with caution to dispose some system resources. Calling the ``++super.finalize()++`` at the end of this method implementation is highly recommended in case parent implementations must also dispose some system resources. == Noncompliant Code Example [source,java] ---- protected void finalize() { // Noncompliant; no call to super.finalize(); releaseSomeResources(); } protected void finalize() { super.finalize(); // Noncompliant; this call should come last releaseSomeResources(); } ---- == Compliant Solution [source,java] ---- protected void finalize() { releaseSomeResources(); super.finalize(); } ---- == See * https://cwe.mitre.org/data/definitions/568[MITRE, CWE-568] - finalize() Method Without super.finalize() * https://wiki.sei.cmu.edu/confluence/x/4jZGBQ[CERT, MET12-J.] - Do not use finalizers ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::message.adoc[] ''' == Comments And Links (visible only on this page) include::comments-and-links.adoc[] endif::env-github,rspecator-view[]