I'm looking for a way of count how many different objects are being called inside a method using ByteBuddy for byte code analysis. I tried this with string parsing, but that's absolutely impossible. Also, I've checked about AST, but I should build the code before doing that, what would be a lot of time. By this, it would be preferable if I could create an agent.
Given the following code:
@Test
public void myMethod(){
Boolean myObj = false;
assertTrue(myObj).isTrue();
assertTrue(myObj2).isTrue();
}
The output for analysis for this method would be: (myObj, myObj2). As I'm new to JavaBuddy, my approach to this would be:
Create an element matcher that would find for methods annotated with @Test . Intercept it .... here's the problem: I don't know how should I count those objects or iterate through method statements.
Can anybody give me some links about it or samples?