-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnnotation.jsp
More file actions
72 lines (57 loc) · 1.26 KB
/
Annotation.jsp
File metadata and controls
72 lines (57 loc) · 1.26 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.lang.annotation.*;
import java.lang.reflect.Field;
@Exploit()
public class Annotationcode {
public @interface Father{
public String css() default "father";
}
@Father(css="dada")
int a;
public static void main(String[] args){
/* boolean hasAnnotation=Annotationcode.class.isAnnotationPresent(Exploit.class);//panduan shifou shiyong zhujie
if(hasAnnotation){
Exploit exploit=Annotationcode.class.getAnnotation(Exploit.class); //huo qu zhu jie duixiang
System.out.println("id:"+exploit.msg());*/
try {
Field a =Annotationcode.class.getDeclaredField("a");
a.setAccessible(true);
Father fa=a.getAnnotation(Father.class);
if(fa!=null){
System.out.println(fa.css());
}
}
catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
}
@interface Father{
public String css() default "father";
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@interface Exploit{
public int id() default 520;
public String msg() default "Hiss";
}
@Exploit
class HelloExp{
}
@Father
class Boy{
}
class girl extends Boy{
}
@interface Persons{
Person[] value();
}
@Repeatable(Persons.class)
@interface Person {
String role();
}
@Person(role="artist")
@Person(role="coder")
@Person(role="PM")
class Chaoren{
String vule="";
}