Skip to content

Commit 50ec9a5

Browse files
Jami CogswellJami Cogswell
Jami Cogswell
authored and
Jami Cogswell
committed
Java: add more test cases
1 parent 90653ed commit 50ec9a5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| Test.java:3:9:3:23 | finalize(...) | Call to 'finalize'. |
1+
| Test.java:4:9:4:23 | finalize(...) | Call to 'finalize'. |
2+
| Test.java:25:9:25:33 | finalize(...) | Call to 'finalize'. |

java/ql/test/query-tests/DoNotUseFinalize/Test.java

+18
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,22 @@ void f() throws Throwable {
77
void f1() throws Throwable {
88
f(); // COMPLIANT
99
}
10+
11+
@Override
12+
protected void finalize() throws Throwable {
13+
// COMPLIANT: If a subclass overrides `finalize`
14+
// it must invoke the superclass finalizer explicitly.
15+
super.finalize();
16+
}
17+
18+
// Overload of `finalize`
19+
protected void finalize(String s) throws Throwable {
20+
System.out.println(s);
21+
}
22+
23+
// NON_COMPLIANT: call to overload of `finalize`
24+
void f2() throws Throwable {
25+
this.finalize("overload"); // $ Alert
26+
}
27+
1028
}

0 commit comments

Comments
 (0)