rspec/rules/S2165/java/rule.adoc

27 lines
616 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
There is no point in setting class fields to ``++null++`` in a finalizer. If this this is a hint to the garbage collector, it is unnecessary - the object will be garbage collected anyway - and doing so may actually cause extra work for the garbage collector.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
public class Foo {
private String name;
@Override
void finalize() {
name = null; // Noncompliant; completely unnecessary
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]