Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] AspectJ M3a: compile error but donot know what'swrong

 
I just downloaded aspectj-DEVELOPMENT-20050906161717.jar, and get the same error message.
I hope it is not a bug because the code works well in AJDT with AspectJ M3a.
 
thanks
 
 
//Subject.java
interface Subject {
 public void addObserver(Observer observer);
 public void removeObserver(Observer observer);
 public Collection getObservers();
}
//Observer.java
interface Observer 
{
 public void update();
}

//ObserverProtocol
public abstract aspect ObserverProtocol{
  abstract pointcut stateChange(Subject subject);
  after(Subject subject):stateChange(subject){
    Iterator it=subject.getObservers().iterator();
    while(it.hasNext()){
         Observer observer=(Observer)it.next();
         observer.update();
    } 
  }
  private Collection Subject.observers=new ArrayList();
  public void Subject.addObserver(Observer observer){
         observers.add(observer);
  }
  public void Subject.removeObserver(Observer observer){
        observers.remove(observer);
  }
  public Collection Subject.getObservers()
  { 
   return observers;
  }
}

________________________________

From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Adrian Colyer
Sent: Tue 9/6/2005 4:25 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] AspectJ M3a: compile error but donot know what'swrong



There's nothing wrong with your code. I tried to reproduce this
problem with the latest AspectJ compiler, but was unable to do so.
What version are you using when you compiled via Ant?

What does Subject look like in your application? I used an empty
interface for my tests...
The behaviour in AJDT looks like it could be related to some kind of
incremental compilation issue. If you do a full build of your project
and the problem goes away then I am even more suspicious of that.
Anyway, please raise a bug report and we can try and diagnose what's
going on there.

Thanks, Adrian.

On 06/09/05, Guofeng Zhang <guofeng@xxxxxxxxxxxxx> wrote:
> The following is the AspectJ code that use Inter-type declarations:
>
> public abstract aspect ObserverProtocol{
>   private Collection Subject.observers=new ArrayList();
>  .....
>   public Collection Subject.getObservers()
>   {
>    return observers;    //line 39
>   }
> }
>
> The following is the output of the compiler.
>      [iajc] D:\workdir\DPsample\main\src\com\designpattern\observer\ObserverProt
> ocol.aj:39 [error] Type mismatch: cannot convert from Collection to Collection
>      [iajc] return observers;
>      [iajc]        ^^^^^
>
> What is wrong with the above code?
>
> In AJDT1.3.0.20050905154239, this line is also marked as x in red. I change this line to
>        return null ;
> the marker disappear, then I change it to
>      return observers;
> again. AJDT still shows that this line is correct, and the program run correctly.
>
> I think maybe this is a bug in M3a.
>
> thanks
>
> guofeng
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


--
-- Adrian
adrian.colyer@xxxxxxxxx
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



<<winmail.dat>>


Back to the top