Community
Participate
Working Groups
Hello, when having an advice for a pointcut expression like: !execution(* *.Test.get*()) this leads to a strange exception when running the compiled program: > java test.Test Exception in thread "main" java.lang.ExceptionInInitializerError at test.Test.<clinit>(Test.java:1) Caused by: org.aspectj.lang.NoAspectBoundException: test_Aspect at test.Aspect.aspectOf(Aspect.aj:1) at test.Aspect.<clinit>(Aspect.aj) ... 1 more It took me a while, to figure out, that such a pointcut expression does not make sense. A sensible combination like !execution(* *.Test.get*()) && execution(* *.*(..)) worked fine. A compiler warning (or even an error) would be desirable when encountering advices for such pointcut expressions. The exception gave me no clue to what was causing the problem. Test case follows. Regards Ben
Created attachment 54493 [details] example to reproduce the bug Example sources to reproduce the behaviour. Compile with ajc test/*.{java,aj} run with java test/Test
Did you try compiling it with '-showWeaveInfo' - so it would tell you that it was advising many more places than you expected?
> Did you try compiling it with '-showWeaveInfo' - so it would tell you that it > was advising many more places than you expected? No, this would have helped indeed. However, I consider the main issue to be, that this causes a crash when running the program. If the advice simply would have been executed a large number of times, I would have spotted the mistake much faster. Even now, I do not understand what caused the crash. Regards Ben