Bug 165810 - Confusing behaviour when using negated pointcut
Summary: Confusing behaviour when using negated pointcut
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-24 13:46 EST by aqualoom CLA
Modified: 2007-10-26 03:58 EDT (History)
1 user (show)

See Also:


Attachments
example to reproduce the bug (1.78 KB, application/x-gzip)
2006-11-24 13:49 EST, aqualoom CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description aqualoom CLA 2006-11-24 13:46:53 EST
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
Comment 1 aqualoom CLA 2006-11-24 13:49:12 EST
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
Comment 2 Andrew Clement CLA 2006-11-28 03:56:40 EST
Did you try compiling it with '-showWeaveInfo' - so it would tell you that it was advising many more places than you expected?
Comment 3 aqualoom CLA 2006-11-28 04:27:11 EST
> 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