java - Agent to count objects inside methods using ByteBuddy -


i'm looking way of count how many different objects being called inside method using bytebuddy byte code analysis. tried string parsing, that's absolutely impossible. also, i've checked ast, should build code before doing that, lot of time. this, preferable if create agent.

given following code:

@test public void mymethod(){     boolean myobj = false;     asserttrue(myobj).istrue();     asserttrue(myobj2).istrue(); } 

the output analysis method be: (myobj, myobj2). i'm new javabuddy, approach be:

create element matcher find methods annotated @test . intercept .... here's problem: don't know how should count objects or iterate through method statements.

can give me links or samples?

in order instrument code within method, byte buddy allows use asm instrument code instruction-wise. reason asm api byte code processing , there no real reason replace end being rather similar.

if want learn asm, their webpage offers great documentation.

nevertheless, intend pretty complex do. have follow control flow of method see object assigned variable @ point in time. also, classes cannot instrumented such boolean class why recommend find approach problem.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -