Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] should undefined concrete pointcuts be an error?

This idiom is new to me and works, but seems bad:

   pointcut matchesNothing();

Just today I've seen it used twice:

- in Ram's book "AspectJ in Action" page 281
- in Ron's bug
  https://bugs.eclipse.org/bugs/show_bug.cgi?id=41124

It seems bad to me because it's very close to another legal
program with almost the opposite meaning:

   abstract pointcut defineMePlease();

The result of this mistake is not detected until runtime,
so it's a costly one.

I know of no other analogous case where an omitted definition
resolves to a negative one. It's like defining the method

   static boolean importantTest();

as

   static boolean importantTest() { return false; }

When the quick reference defines the general form
for named pointcuts, it instead requires a pointcut
for non-abstract pointcuts:

  abstract [Modifiers] pointcut Id ( Formals )  ;
  [Modifiers] pointcut Id ( Formals ) : Pointcut ;

So, I believe the compiler should emit an error when a
concrete pointcut is not defined.  To actually say
the first thing, one can do so explicitly:

   pointcut matchesNothing() :
        call(IOException thisPointcutMatchesNothing());

or, if the compiler should staticly evaluate if():

   pointcut matchesNothing() : if(false);

Making it an error might also make it easier to write
parsers for AspectJ.

On the other hand, this idiom works in both 1.0 and 1.1,
and there might be AspectJ programs in the wild that
use it.  I hate to break programs, but I also hate to
be bug-compatible and support valid but broken programs.

So we should write an XLint message for this.

The default level would be error if we agree it is an error
and warning otherwise.  If it's an error, the message text
can say this form will not be permitted in AspectJ 1.2,
but users can disable the error until then in order
to avoid having to rewrite their code.

So:
- is this idiom is an error?
- objections to adding an XLint message in any case?
  - is this message required for 1.1.1?
  - does anyone care to offer guidance on writing
    the XLint test?

Wes




Back to the top