Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Java: add more test cases
  • Loading branch information
Jami Cogswell authored and Jami Cogswell committed Mar 27, 2025
commit c689a0e9b718ff14fd5923e25c0b57224badf64b
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
| Test.java:3:9:3:23 | finalize(...) | Call to 'finalize'. |
| Test.java:4:9:4:23 | finalize(...) | Call to 'finalize'. |
| Test.java:25:9:25:33 | finalize(...) | Call to 'finalize'. |
18 changes: 18 additions & 0 deletions java/ql/test/query-tests/DoNotUseFinalize/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,22 @@ void f() throws Throwable {
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
}

}