I'm trying to log read and write accesses with aspectJ. To do this, I want to capture the constructor calls, read and write calls and close calls of, for example, RandomAccessFile objects. The logged data shall be saved inside the aspect. For this reason, I want to use pertarget to capture constructor invocations. The problem is, that the used pointcut doesn't seem to work; neither an aspect instance is created, nor the advice for the constructor is used; i get a "advice has not been applied" message.
These are the pointcuts used to capture the constructor calls.
public pointcut randomAccessFileCreation() : call(RandomAccessFile.new(..)); public pointcut writerCreation() : (call(FileWriter.new(..)) || call(PrintWriter.new(File,..)) || call(PrintWriter.new(String,..)));
These pointcuts (and more, for example readerCreation() following the same principle) are joined with the newAspect() pointcut:
public pointcut newAspect() : writerCreation() || randomAccessFileCreation();
The aspect is defined like this: public privileged aspect loggingAspect pertarget(newAspect()){