All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.ObjectFinalizeOverridenCheck.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

This Object.finalize() method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. But there is absolutely no warranty that this method will be called AS SOON AS the last references to the object are removed. It can be few microseconds to few minutes later. So when some system resources need to be disposed by an object, it's better to not rely on this asynchronous mechanism to dispose them.

Noncompliant Code Example

public class MyClass {
  ...
  protected void finalize() {
    releaseSomeResources();    // Noncompliant
  }
  ...
}

See

  • CERT Java Secure Coding, MET12-J - Do not use finalizers




© 2015 - 2025 Weber Informatics LLC | Privacy Policy