forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflectionTest.java
More file actions
28 lines (24 loc) · 808 Bytes
/
ReflectionTest.java
File metadata and controls
28 lines (24 loc) · 808 Bytes
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
public class ReflectionTest {
public static class ParentClass {
// Not live
private int notInheritedField;
// Live because it is accessed through ChildClass
public int inheritedField;
// Not live because it is shadowed by the child
public int shadowedField;
}
public static class ChildClass extends ParentClass {
// Live field, accessed directly
private int notInheritedField;
// Live field, accessed directly
public int shadowedField;
}
public static void main(String[] args) throws NoSuchFieldException {
// Ensure the two classes are live, otherwise we might hide some results
new ParentClass();
new ChildClass();
ChildClass.class.getDeclaredField("notInheritedField");
ChildClass.class.getField("inheritedField");
ChildClass.class.getField("shadowedField");
}
}