mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Java: add previous-id and change 'use' to 'call'
This commit is contained in:
28
java/ql/test/query-tests/DoNotCallFinalize/Test.java
Normal file
28
java/ql/test/query-tests/DoNotCallFinalize/Test.java
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
|
||||
// NON_COMPLIANT: call to overload of `finalize`
|
||||
void f2() throws Throwable {
|
||||
this.finalize("overload"); // $ Alert
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user