Bug 419038

Summary: Support literals "true" & "false" in expressions
Product: [Tools] AspectJ Reporter: Matthew Adams <matthew>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 1.7.4   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

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+;
}
=====