Пример кода:
Код: Выделить всё
package org.example.aspectj;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class TimeAspect
{
@Around("execution(public static native long currentTimeMillis())")
public long changeCallsToCurrentTimeInMillisMethod(ProceedingJoinPoint pjp)
{
return 0;
}
}
Код: Выделить всё
package org.example.aspectj;
public class TimeDemo
{
public static void main(String[] args) {
long currentTimeMillis = System.currentTimeMillis();
System.out.println("currentTimeMillis -> " + currentTimeMillis);
}
}
Код: Выделить всё
[warning] advice defined in org.example.aspectj.TimeAspect has not been applied [Xlint:adviceDidNotMatch]
Код: Выделить всё
Task :TimeDemo.main()
currentTimeMillis -> 1710770641050
Что не так?
Подробнее здесь: https://stackoverflow.com/questions/781 ... ia-aspectj