forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuppressedConstructorTest.java
More file actions
37 lines (30 loc) · 1.03 KB
/
SuppressedConstructorTest.java
File metadata and controls
37 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class SuppressedConstructorTest {
private static class SuppressedConstructor {
// This should not be reported as dead
private SuppressedConstructor() { }
public static void liveMethod() { }
}
public void deadMethod() {
new NestedPrivateConstructor();
}
private static class NestedPrivateConstructor {
// This should be dead, because it is called from a dead method.
private NestedPrivateConstructor() { }
public static void liveMethod() { }
}
private static class OtherConstructor {
/*
* This should be marked as dead. There is another constructor declared, so no default
* constructor will be added by the compiler. Therefore, we do not need to declare this private
* in order to suppress it.
*/
private OtherConstructor() { }
// Live constructor
private OtherConstructor(Object foo) { }
}
public static void main(String[] args) {
new OtherConstructor(new Object());
SuppressedConstructor.liveMethod();
NestedPrivateConstructor.liveMethod();
}
}