Bug 436653 - SuppressAjWarnings for type not found messages that could occur at a later weave time
Summary: SuppressAjWarnings for type not found messages that could occur at a later we...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.0   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-05 00:56 EDT by Andrew Clement CLA
Modified: 2014-10-21 16:15 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 Andrew Clement CLA 2014-06-05 00:56:37 EDT
When a point cut refers to a type, and that type cannot be found:

pointcut p(): execution(* *(..)) && (within(@Foo *) || within(@Bar *));

it may not be the end of the world (e.g. if Foo is missing above, the pointcut may still be OK and match).

When this occurs we produce a cantFindType message.

Feels like it should be possible to express that this shouldn't be a fatal problem using something like SuppressAjWarnings on the pointcut
Comment 1 Andrew Clement CLA 2014-10-21 16:14:44 EDT
For 1.8.3 I've actually implemented a high level feature to ease this problem. Namely @RequiredTypes:

@RequiredTypes("some.fully.qualified.Type")
aspect Foo {

This annotation applies to an aspect and takes a list of strings. Each string is a fully qualified type name. If the type cannot be found on the class path the aspect is 'turned off' and it will have no effect on the system. This is useful in environments like spring where the spring-aspects library includes a number of aspects covering different domains but all packaged together. If a user is not exploiting a particular technology they don't want the aspect related to that tech firing but because all the aspects are in one jar with the aop.xml file, they'll all be turned on. This means even though the aspect will do nothing (pointcuts within it won't match because the developer isn't doing anything that might match) the developer must include some dependencies on the aspect library in order to avoid nasty 'cant find type' messages when the aspects attempt to get applied.  @RequiredTypes means if those dependencies are not around, the aspects are turned off (== no more can't find type).
Comment 2 Andrew Clement CLA 2014-10-21 16:15:16 EDT
What was/is originally proposed in this bugs is a more granular control, which I still think we may need, so leaving this bug open.