Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get values of method's parameters?

I have the aspect:

public aspect TestAspect {
    pointcut publicMethodExecuted(): execution(public !static * *(..));

    int around() : publicMethodExecuted() {
        //I need parameters values here
        //to write their to log

        int original_return_value = proceed();
        return original_return_value * 100;
    }
}

How to get parameters the method was called with? I need to write their to log file.

I'm most interested in a native AspectJ-way, not using reflection.

like image 410
St.Antario Avatar asked Dec 24 '22 19:12

St.Antario


1 Answers

Sorry If I misunderstood but this should bring the parameters

Object[] args = thisJoinPoint.getArgs();
like image 174
dogant Avatar answered Jan 02 '23 10:01

dogant