31 lines
553 B
Plaintext
31 lines
553 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
fun main() {
|
||
|
...
|
||
|
System.runFinalizersOnExit(true) // Noncompliant
|
||
|
...
|
||
|
}
|
||
|
----
|
||
|
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
fun main() {
|
||
|
Runtime.getRuntime().addShutdownHook(object : Thread() {
|
||
|
override fun run() {
|
||
|
doSomething()
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
----
|
||
|
|
||
|
|
||
|
== See
|
||
|
|
||
|
* https://wiki.sei.cmu.edu/confluence/x/4jZGBQ[CERT, MET12-J.] - Do not use finalizers. Although this resource talks about Java, the underlying information concerning the JVM are just as relevant for Kotlin.
|
||
|
|