pointcut execution for specific class constructor

547 views Asked by At

I'm trying to create specific class constructor pointcut execution but I get the following marker: pointcut marker error
Aspect code:

public aspect CarLogger {
private Logger logger;

pointcut instantiate() : execution (Car.new(..));  

after() : instantiate(){
    logger.log(Level.INFO, "In Car::Car()", thisJoinPoint.getThis());
}

this code returns no match for this type name Car. But if I change execution (Car.new(..)) to execution (*.new(..)) I get all constructors in the project.
My wish is to have the pointcut execute only to the specific class Car

1

There are 1 answers

1
Naman Gala On BEST ANSWER

I think it is because pointcut is not able to map Car with your class, as you have not specified proper path to it i.e. full name along with package.

pointcut instantiate() : execution (com.abc.vehicle.Car.new(..));