Gil Peretz
Gil Peretz

Reputation: 2419

pointcut execution for specific class constructor

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

Upvotes: 0

Views: 536

Answers (1)

Naman Gala
Naman Gala

Reputation: 4692

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(..)); 

Upvotes: 1

Related Questions