rspec/rules/S2151/java/rule.adoc
2022-02-04 16:28:24 +00:00

52 lines
790 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
[source,java]
----
public static void main(String [] args) {
...
System.runFinalizersOnExit(true); // Noncompliant
...
}
protected void finalize(){
doSomething();
}
----
== Compliant Solution
[source,java]
----
public static void main(String [] args) {
Runtime.addShutdownHook(new Runnable() {
public void run(){
doSomething();
}
});
//...
----
== See
* 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[]