This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Issue switching from AspectJ to Spring AOP

Jun 25th, 2007, 07:52 PM

Our system has a number of security checking @Aspect aspects and we have recently switched over from using the AspectJ weaver to Spring AOP but unfortunately it appears that the Spring AOP does not implement the full point cut model from AspectJ and these aspects are now failing to function correctly.

These problem aspects all have pointcuts that include return parameters with generic types (namely collections) and what appears to be happening is Spring AOP ignores the generic type parameters causing the pointcut to match a much wider set of join points.

AspectJ will apply the foosChecker aspect only to the getSomeFoos method and the barsChecker aspect to the getSomeBars method.

Spring AOP on the other hand ignores the generic type and applies the foosChecker and barsChecker aspects to both methods which results in class cast exceptions a plenty.

I did a quick search though Jira and could only find SPR-3556 which may be related.

What are the possible work arounds for this? Obviously I can creating a single uber collection aspect that then delegates to the correct sub-aspects once it's worked out the collection element type but this is a hack I'd rather avoid.