Java - how to analyze a function code


Java - how to analyze a function code



We are working with mvc design pattern, where all the data is stored under map.



I want to iterate over all the classes in the system and for each to check what the method is putting on the map and what does the method get from the map.



For example for the next code:


private void myFunc()
{
Object obj = model.get("mykey");
Object obj2 = model.get("mykey2");
.....
model.put("mykey3", "aaa");
}



I want to know that in this function we have 2 gets: mykey and mykey2 and 1 put: mykey3



How can I do it with the code.



Thanks.




1 Answer
1



You tagged this with "reflection", but that will not work.



Reflection only allows you to inspect "signatures". You can use it to identify the methods of a class, and the arguments of the methods.



It absolutely doesn't help you to identify what each method is doing.



In order to find out about that, you would need to either parse the java source code side, or byte code classes. As in: write code that reads that content, and understands "enough" of it to find such places. Which is a very challenging effort.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV