== Why is this an issue? ``++Object.finalize()++`` is called by the Garbage Collector at some point after the object becomes unreferenced. In general, overloading ``++Object.finalize()++`` is a bad idea because: * The overload may not be called by the Garbage Collector. * Users are not expected to call ``++Object.finalize()++`` and will get confused. But beyond that it's a terrible idea to name a method "finalize" if it doesn't actually override ``++Object.finalize()++``. === Noncompliant code example [source,java] ---- public int finalize(int someParameter) { // Noncompliant /* ... */ } ---- === Compliant solution [source,java] ---- public int someBetterName(int someParameter) { // Compliant /* ... */ } ---- ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) === Message Rename this method to avoid any possible confusion with Object.finalize() or [remove the parameters|give it a "void" return type]. ''' == Comments And Links (visible only on this page) === on 1 Aug 2013, 13:21:52 Freddy Mallet wrote: Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-264 === on 1 Aug 2013, 23:28:32 Ann Campbell wrote: The description says that the lower-level finalize won't be called, but that's not what my reading indicates...? === on 2 Aug 2013, 06:26:50 Dinesh Bolkensteyn wrote: How many rules do we need on Object.finalize()? We already have 3, and I think that having 5 is really too much to cover a feature that in practice is never used... It probably would be better to see how those 2 new rules could be fit into the existing 3 rules use cases === on 2 Aug 2013, 07:38:10 Dinesh Bolkensteyn wrote: Methods should not be named 'finalize' === on 2 Aug 2013, 08:25:35 Freddy Mallet wrote: Just to make it clear, in such case we're really talking about overloading and not about overriding. === on 2 Feb 2015, 20:57:10 Sébastien Gioria wrote: CERT Secure Coding MET12-J === on 3 Feb 2015, 20:39:26 Ann Campbell wrote: I see this as a different issue [~sebastien.gioria]. === on 16 Jun 2015, 11:47:56 Ann Campbell wrote: CodePro: Finalize Method Definition endif::env-github,rspecator-view[]