Open liberatorqjw opened 5 years ago
Are you analyzing source code or bytecode?
On Thu, Oct 24, 2019 at 00:02 Jiawei Qin notifications@github.com wrote:
jdk: 1.8
my example is a spring demo. I write as follows: but i get the getAnnotations() is always null. Spring demo
@RestController
@RequestMapping(value="/test")
public class TestCtrl {
@Autowired
private RedisService redisService;
@Autowired
private UserInfoMapper userInfoMapper; @RequestMapping(value="/index") public String index(){ return "hello world"; } /** * 向redis存储值 * @param key * @param value * @return * @throws Exception */ @RequestMapping("/set") public String set(String key, String value) throws Exception{ redisService.set(key, value); return "success"; } /** * 获取redis中的值 * @param key * @return */ @RequestMapping("/get") public String get(String key){ try { return redisService.get(key); } catch (Exception e) { e.printStackTrace(); } return ""; }
wala demo
for (IClass klass : cha) { if (klass.getClassLoader().getReference().equals(clr)) { //TODO: REFACTOR OOP/ Maybe with a list if (klass.getName().toString().startsWith("Lorg/springframework")) continue; if (klass.getAnnotations() == null) continue; for (Annotation annotation : klass.getAnnotations()) { if (isSpringComponent(annotation,cha)) { //check for class methods as entry points //TODO: Grab only methods mapped for (IMethod iMethod : klass.getAllMethods()) { if (isSpringMapping(iMethod)) { result.add(new SpringEntrypoint(iMethod,cha)); } } } }
// IMethod m = klass.getMethod(mainRef.getSelector());
// if (m != null) {
// result.add(new DefaultEntrypoint(m, cha));
// }
} }
Thanks
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wala/WALA/issues/574?email_source=notifications&email_token=AABPEUM22ERBG3CIJCPWKVDQQFCBLA5CNFSM4JEPWON2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HUAVHUQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPEULBF72ZLFKXXKFYOATQQFCBLANCNFSM4JEPWONQ .
I analyzed the source code as follows:
scope.addToScope(ClassLoaderReference.Application, new SourceDirectoryTreeModule(new File(sourceDir)));
// build the class hierarchy
IClassHierarchy cha = ClassHierarchyFactory.make(scope, new com.ibm.wala.cast.java.translator.jdt.ecj.ECJClassLoaderFactory(scope.getExclusions()));
//
Ok, yes, this is using the source front end. @juliandolby are annotations supported in the source front end?
I can not get the @requestmapping and any more class annotions
Hi @juliandolby, @msridhar : Does the java source code support recognition class's annotations? or Or which mode supports this kind of operation?
Thanks
Annotations are definitely supported in the bytecode frontend. @juliandolby would know about source front end.
Ok, Thanks for your help I am looking forward to hear from @juliandolby
jdk: 1.8
my example is a spring demo. I write as follows: but i get the getAnnotations() is always null. Spring demo
wala demo
Thanks