Bug 140357 - NPE or StackOverflow when resolving reference pointcut in ReflectionWorld
Summary: NPE or StackOverflow when resolving reference pointcut in ReflectionWorld
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P2 normal (vote)
Target Milestone: 1.5.2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-05 09:43 EDT by Adrian Colyer CLA
Modified: 2007-07-29 09:19 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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