Bug 419038 - Support literals "true" & "false" in expressions
Summary: Support literals "true" & "false" in expressions
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.4   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-09 09:51 EDT by Matthew Adams CLA
Modified: 2013-10-09 09:51 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 Matthew Adams CLA 2013-10-09 09:51:43 EDT
The forms "if(true)" & "if(false)" are supposed to be used in pointcuts to convey a literal "true" & "false", respectively.  However, if() is disallowed in declare error & declare warning statements.  Further, the literals, IMHO, are more intuitive than the if() form.

I'd like to replace the use of Bool in the workaround below with the literals.

public final aspect Bool {
  public static final pointcut true_(): within(*);
  public static final pointcut false_(): !true_();
}
=====
public abstract aspect Super {

  public abstract pointcut qualifyingUsage();
  public pointcut warnOnBadUseOfAnnotation():  Bool.false_(); // default

  declare warning:
    warnOnBadUseOfAnnotation() && qualifyingUsage():
    "incorrect usage of annotation";
}
=====
public aspect Sub {
  public warnOnBadUseOfAnnotation():  Bool.true_(); // override

  public pointcut qualifyingUsage():
    @NotSerializable Serializable+;
}
=====

Example using proposed literals:

=====
public abstract aspect Super {

  public abstract pointcut qualifyingUsage();
  public pointcut warnOnBadUseOfAnnotation():  false; // default

  declare warning:
    warnOnBadUseOfAnnotation() && qualifyingUsage():
    "incorrect usage of annotation";
}
=====
public aspect Sub {
  public warnOnBadUseOfAnnotation():  true; // override

  public pointcut qualifyingUsage():
    @NotSerializable Serializable+;
}
=====