@@ -28,6 +28,7 @@ public void testRemoval() throws Exception {
28
28
assertThat (type .getAnnotations ().length , is (0 ));
29
29
assertThat (type .getDeclaredField (FOO ).getAnnotations ().length , is (0 ));
30
30
assertThat (type .getDeclaredConstructor ().getAnnotations ().length , is (0 ));
31
+ assertThat (type .getDeclaredMethod (FOO , Void .class ).getParameterAnnotations ()[0 ].length , is (0 ));
31
32
assertThat (type .getDeclaredMethod (BAR ).getAnnotations ().length , is (0 ));
32
33
}
33
34
@@ -42,6 +43,7 @@ public void testRemovalOnType() throws Exception {
42
43
assertThat (type .getAnnotations ().length , is (0 ));
43
44
assertThat (type .getDeclaredField (FOO ).getAnnotations ().length , is (1 ));
44
45
assertThat (type .getDeclaredConstructor ().getAnnotations ().length , is (1 ));
46
+ assertThat (type .getDeclaredMethod (FOO , Void .class ).getParameterAnnotations ()[0 ].length , is (1 ));
45
47
assertThat (type .getDeclaredMethod (BAR ).getAnnotations ().length , is (1 ));
46
48
}
47
49
@@ -56,6 +58,7 @@ public void testRemovalOnField() throws Exception {
56
58
assertThat (type .getAnnotations ().length , is (1 ));
57
59
assertThat (type .getDeclaredField (FOO ).getAnnotations ().length , is (0 ));
58
60
assertThat (type .getDeclaredConstructor ().getAnnotations ().length , is (1 ));
61
+ assertThat (type .getDeclaredMethod (FOO , Void .class ).getParameterAnnotations ()[0 ].length , is (1 ));
59
62
assertThat (type .getDeclaredMethod (BAR ).getAnnotations ().length , is (1 ));
60
63
}
61
64
@@ -70,6 +73,7 @@ public void testRemovalOnConstructor() throws Exception {
70
73
assertThat (type .getAnnotations ().length , is (1 ));
71
74
assertThat (type .getDeclaredField (FOO ).getAnnotations ().length , is (1 ));
72
75
assertThat (type .getDeclaredConstructor ().getAnnotations ().length , is (0 ));
76
+ assertThat (type .getDeclaredMethod (FOO , Void .class ).getParameterAnnotations ()[0 ].length , is (1 ));
73
77
assertThat (type .getDeclaredMethod (BAR ).getAnnotations ().length , is (1 ));
74
78
}
75
79
@@ -84,9 +88,25 @@ public void testRemovalOnMethod() throws Exception {
84
88
assertThat (type .getAnnotations ().length , is (1 ));
85
89
assertThat (type .getDeclaredField (FOO ).getAnnotations ().length , is (1 ));
86
90
assertThat (type .getDeclaredConstructor ().getAnnotations ().length , is (1 ));
91
+ assertThat (type .getDeclaredMethod (FOO , Void .class ).getParameterAnnotations ()[0 ].length , is (1 ));
87
92
assertThat (type .getDeclaredMethod (BAR ).getAnnotations ().length , is (0 ));
88
93
}
89
94
95
+ @ Test
96
+ public void testRemovalOnMethodParameter () throws Exception {
97
+ Class <?> type = new ByteBuddy ()
98
+ .redefine (Sample .class )
99
+ .visit (AnnotationRemoval .strip (ElementMatchers .annotationType (named (SampleAnnotation .class .getName ()))).onMethods (named (FOO )))
100
+ .make ()
101
+ .load (SampleAnnotation .class .getClassLoader (), ClassLoadingStrategy .Default .CHILD_FIRST_PERSISTENT )
102
+ .getLoaded ();
103
+ assertThat (type .getAnnotations ().length , is (1 ));
104
+ assertThat (type .getDeclaredField (FOO ).getAnnotations ().length , is (1 ));
105
+ assertThat (type .getDeclaredConstructor ().getAnnotations ().length , is (1 ));
106
+ assertThat (type .getDeclaredMethod (FOO , Void .class ).getParameterAnnotations ()[0 ].length , is (0 ));
107
+ assertThat (type .getDeclaredMethod (BAR ).getAnnotations ().length , is (1 ));
108
+ }
109
+
90
110
@ SampleAnnotation
91
111
private static class Sample {
92
112
0 commit comments