forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnnotationValueTest.java
More file actions
43 lines (35 loc) · 1.23 KB
/
AnnotationValueTest.java
File metadata and controls
43 lines (35 loc) · 1.23 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
38
39
40
41
42
43
public class AnnotationValueTest {
public static @interface TestAnnotation {
public String[] value();
}
@TestAnnotation(value = AnnotationValueUtil.LIVE_STRING_CONSTANT_FIELD)
public static String liveField = "";
@TestAnnotation(value = AnnotationValueUtil.DEAD_STRING_CONSTANT_FIELD)
public static String deadField = "";
@TestAnnotation(value = { AnnotationValueUtil.LIVE_STRING_CONSTANT_METHOD })
public static void liveMethod() {
}
@TestAnnotation(value = AnnotationValueUtil.DEAD_STRING_CONSTANT_METHOD)
public static void deadMethod() {
}
/**
* Class is live because it is constructed in the main method, which in turn should make this
* annotation live, causing LIVE_STRING_CONSTANT_CLASS to be live because it is read in the
* annotation.
*/
@TestAnnotation(value = AnnotationValueUtil.LIVE_STRING_CONSTANT_CLASS + "..")
public static class LiveClass {
}
/**
* This class is dead, so the annotation is dead, and the field read of
* DEAD_STRING_CONSTANT_CLASS will not make the field live.
*/
@TestAnnotation(value = AnnotationValueUtil.DEAD_STRING_CONSTANT_CLASS)
public static class DeadClass {
}
public static void main(String[] args) {
System.out.println(liveField);
liveMethod();
new LiveClass();
}
}