Bug 237697 - Fine grained control over weaving
Summary: Fine grained control over weaving
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-18 16:54 EDT by Andrew Clement CLA
Modified: 2013-06-24 11:06 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2008-06-18 16:54:51 EDT
From Chris Beams.

He has an environment where he uses development aspects in his project to police certain things.  At the same time he also has some malformed aspects where he wants to produce his own suitable error messages.  Effectively he has something like:

import org.aspectj.lang.annotation.*;

@Aspect
public class Broken {

@Before("bogus")
public void m() {}
}

And basically he wants to pass it through ajc with the rest of the code, but does not want it treated like an aspect, rather have it treated as if it had been through javac.

We have the option -Xdev:NoAtAspectJProcessing but that just stops any processing during the compilation stage (ajc does extra processing when encountering annotation style aspects if it can), and the weaver then fails with an error about the pointcut instead.

options we have just talked about:
- an annotation on the type that marks it as 'leave me alone'
- a comment style thing //AJ:OFF
- ui preference for a project that specifies a pattern (pointcut?) on what to exclude

Only the first of those appeals to me right now.

This would actually aid our own aspectj testing as it is hard to test some annotation style problems because we dont easily have a well known level of javac defined that we can use, but we *do* have ajc, we just cant configure ajc to behave like javac right now.

We also have the flag -XterminateAfterCompilation.  However, both this and the NoAtAspectJProcessing are global, they are not fine grained controls that allow behaviour to vary on a per-aspect basis.

If -Xdev:NoAtAspectJProcessing were extended with a regex list, I wonder if that would be enough:

-Xdev:NoAtAspectJProcessing:(com.foo.something.*,com.goo.something.IgnoreMe)

I know a pointcut is ideal but faking up enough environment to parse a pointcut on the end of an option would be hard.

The problem is to ensure the weaver doesn't go digging around for pointcuts/itds/etc in the types and right now it does that through many routes.
Comment 1 Andrew Clement CLA 2008-06-18 16:58:43 EDT
Although maybe as the aspect will never be valid, it should be more permanently
marked as such, with an annotation or comment.  The setting for -Xdev would be
lost as the code is moved from development to the build system (I would bet...)
and then the build system will crash.  If it were attached more permanently to
the aspect, this wouldn't happen.
Comment 2 Chris Beams CLA 2008-06-18 17:03:51 EDT
With regard to exclusion via pointcut, I can certainly understand the bootstrapping problem you're referring to.

As a variation on number #1 (exclusion via annotation), perhaps an @IgnoreAjErrors annotation would be reasonable?  The semantics here would be similar to the existing @IgnoreAjWarnings: Rather than telling AJ to avoid processing this aspect, it would say "just don't complain about any errors you find when you DO process it".  Either of these two approaches would still get me as a user the desired functionality.
Comment 3 Andrew Clement CLA 2013-06-24 11:06:03 EDT
unsetting the target field which is currently set for something already released