Bug 112756 - ajdt compiler generate false warnings
Summary: ajdt compiler generate false warnings
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M4   Edit
Hardware: Other other
: P2 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-16 23:56 EDT by Eugene Kuleshov CLA
Modified: 2005-11-09 05:40 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Kuleshov CLA 2005-10-16 23:56:55 EDT
I was working on aspect that should raise an error for junit test methods that didn't
use any assertions. Apparently I had to use pointcut like "call(void Assert+.assert*(..))"
on which ajdt compiler complained about using "assert" keyword. I don't think such warning
should be shown in such case.

Anyway, here is the complete aspect code.


import
junit.framework.Test;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;


public
aspect AssertionCounter {
  private ThreadLocal counts = new ThreadLocal();

  public
pointcut testMethodExecution() : 
    execution(void Test+.test*());

  public pointcut
assertCall() : 
    cflow(testMethodExecution()) && call(void Assert+.assert*(..));

 
  
  void around() : testMethodExecution() {
    counts.set( new Counter());
  
 proceed();
    if(((Counter) counts.get()).getCount()==0) {
      throw new AssertionFailedError("No
assertions had been called");
    }
  }

  before() : assertCall() {
    ((Counter)
counts.get()).inc();
  }
  
}
Comment 1 Adrian Colyer CLA 2005-11-09 05:40:39 EST
The code to generate the warning was deep in the JDT parser. This issue (and a related one of using 
"enum" inside a pointcut expression in a similar way) is now fixed... by an aspect that suppresses the 
warning if made whilst processing a pseudo-token stream.

Fix will be available in next published build from AspectJ downloads page, and incorporated into AJDT on 
Monday of next week (21st).