44 lines
939 B
Plaintext
44 lines
939 B
Plaintext
``++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
|
|
|
|
----
|
|
public int finalize(int someParameter) { // Noncompliant
|
|
/* ... */
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
public int someBetterName(int someParameter) { // Compliant
|
|
/* ... */
|
|
}
|
|
----
|
|
|
|
|
|
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[]
|