Bug 140357

Summary: NPE or StackOverflow when resolving reference pointcut in ReflectionWorld
Product: [Tools] AspectJ Reporter: Adrian Colyer <adrian.colyer>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2    
Version: 1.5.1   
Target Milestone: 1.5.2   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Adrian Colyer CLA 2006-05-05 09:43:03 EDT
Given a type such as :

private static class NamedPointcutResolution {
		
  @Pointcut("execution(* *(..))")
  public void a() {}
		
		  
  @Pointcut("this(org.aspectj.weaver.tools.Java15PointcutExpressionTest.A)")
  public void b() {}
		
  @Pointcut("a() && b()")
  public void c() {}

}

The reflection based delegate is unable to resolve the pointcut c() failing
with either (1) an NPE, or (2) a StackOverflow, depending on the order of the
pointcut definitions in the type.

The problem occurs because in resolving "c()" we get all the pointcuts in the
type, which gets a(), b(), and c(), and tries to resolve them...
Comment 1 Adrian Colyer CLA 2006-05-05 09:45:21 EDT
To solve this I had to split the getDeclaredPointcuts operation in Java15ReflectionBasedDelegate into 3 distinct phases:

first populate the pointcuts array with DeferredResolvedPointcutDefinitions :- these know there name and parameters, but not yet the Pointcut object they contain.

secondly resolve all the pointcuts

thirdly concretize all the pointcuts

Driving through these phases in this order (as oppose to trying to resolve and concretize the first pointcut before the others have even been defined) prevents the errors described.
Comment 2 Adrian Colyer CLA 2006-05-05 09:45:57 EDT
.. this is a high priority bug for the Spring community
Comment 3 Adrian Colyer CLA 2006-05-05 10:17:54 EDT
fix committed in tree.
Comment 4 Andrew Clement CLA 2006-05-16 09:09:28 EDT
fix available
Comment 5 Eclipse Webmaster CLA 2007-07-29 09:19:47 EDT
Changing OS from Mac OS to Mac OS X as per bug 185991