Files
codeql/java/ql/test/query-tests/DoNotCallFinalize/Test.java
2025-03-27 19:35:46 -04:00

29 lines
655 B
Java

public class Test {
void f() throws Throwable {
// NON_COMPLIANT
this.finalize(); // $ Alert
}
void f1() throws Throwable {
f(); // COMPLIANT
}
@Override
protected void finalize() throws Throwable {
// COMPLIANT: If a subclass overrides `finalize()`
// it must invoke the superclass finalizer explicitly.
super.finalize();
}
// Overload of `finalize`
protected void finalize(String s) throws Throwable {
System.out.println(s);
}
// COMPLIANT: call to overload of `finalize`
void f2() throws Throwable {
this.finalize("overload");
}
}