7 files changed +59
-2
lines changed Original file line number Diff line number Diff line change
1
+ import java .lang .annotation .Retention ;
2
+ import java .lang .annotation .RetentionPolicy ;
3
+ import java .lang .annotation .ElementType ;
4
+ import java .lang .annotation .Target ;
5
+
6
+
7
+
8
+ @ Retention (RetentionPolicy .RUNTIME )
9
+ @ Target (ElementType .TYPE )
10
+ @interface InterfaceVisibleAnnotation {
11
+
12
+ }
13
+
14
+ @ InterfaceVisibleAnnotation
15
+ public class VisibleAnnotation {
16
+
17
+ }
18
+
19
+
Original file line number Diff line number Diff line change @@ -115,14 +115,20 @@ private static Stream<JavaAnnotationSootMethod> resolveMethods(
115
115
MethodSignature methodSignature =
116
116
signatureFactory .getMethodSignature (cs , methodName , retType , sigTypes );
117
117
118
+ List <AnnotationNode > annotations = new ArrayList <>();
119
+ if (methodSource .visibleAnnotations != null )
120
+ annotations .addAll (methodSource .visibleAnnotations );
121
+ if (methodSource .invisibleAnnotations != null )
122
+ annotations .addAll (methodSource .invisibleAnnotations );
123
+
118
124
// TODO: position/line numbers if possible
119
125
120
126
return new JavaAnnotationSootMethod (
121
127
asmClassClassSourceContent ,
122
128
methodSignature ,
123
129
modifiers ,
124
130
exceptions ,
125
- convertAnnotation (methodSource . invisibleAnnotations ),
131
+ convertAnnotation (annotations ),
126
132
NoPositionInformation .getInstance ());
127
133
});
128
134
}
Original file line number Diff line number Diff line change @@ -128,13 +128,19 @@ public Collection<? extends SootMethod> resolveMethods() throws ResolveException
128
128
identifierFactory .getMethodSignature (
129
129
classSignature , methodName , retType , sigTypes );
130
130
131
+ List <AnnotationNode > annotations = new ArrayList <>();
132
+ if (methodSource .visibleAnnotations != null )
133
+ annotations .addAll (methodSource .visibleAnnotations );
134
+ if (methodSource .invisibleAnnotations != null )
135
+ annotations .addAll (methodSource .invisibleAnnotations );
136
+
131
137
// TODO: position/line numbers if possible
132
138
return new JavaSootMethod (
133
139
asmClassClassSourceContent ,
134
140
methodSignature ,
135
141
modifiers ,
136
142
exceptions ,
137
- convertAnnotation (methodSource . invisibleAnnotations ),
143
+ convertAnnotation (annotations ),
138
144
NoPositionInformation .getInstance ());
139
145
})
140
146
.collect (Collectors .toSet ());
Original file line number Diff line number Diff line change
1
+ package sootup .java .bytecode .minimaltestsuite .java6 ;
2
+
3
+ import static org .junit .Assert .assertEquals ;
4
+
5
+ import java .util .*;
6
+ import org .junit .Test ;
7
+ import sootup .core .signatures .PackageName ;
8
+ import sootup .java .bytecode .minimaltestsuite .MinimalBytecodeTestSuiteBase ;
9
+ import sootup .java .core .AnnotationUsage ;
10
+ import sootup .java .core .JavaSootClass ;
11
+ import sootup .java .core .types .AnnotationType ;
12
+
13
+ public class VisibleAnnotationTest extends MinimalBytecodeTestSuiteBase {
14
+
15
+ @ Test
16
+ public void testVisibleAnnotationOnClassOrAnnotation () {
17
+ JavaSootClass sootClass = loadClass (getDeclaredClassSignature ());
18
+
19
+ assertEquals (
20
+ Arrays .asList (
21
+ new AnnotationUsage (
22
+ new AnnotationType ("InterfaceVisibleAnnotation" , new PackageName ("" ), false ),
23
+ Collections .emptyMap ())),
24
+ sootClass .getAnnotations (Optional .of (customTestWatcher .getJavaView ())));
25
+ }
26
+ }
0 commit comments