Any class does not finalize().
When the object is how to deal with recycling.
If I understood you correct, you’re asking how to override finalize
method, given that Any
object does not define it.
All you need to do is simply declare it, without using the override
keyword:
class C {
protected fun finalize() {
// finalization logic
}
}
More on this in the reference: https://kotlinlang.org/docs/reference/java-interop.html#object-methods