I already had the interface Ola if that's what you mean, i just forgot to
write it here.
I have AspectJ 1.5
I could make this work if i create an aspect and put all the code in the
same aspect but if i try to separate in 3 different classes
if i put this code in one aspect it works
interface Ola {}
class Client {
public Client(){}
public void aux() {
Ola o = new Client();
}
}
public aspect X {
declare parents: Client implements Ola;
}
but if create an aspect X, an interface Ola and a class Client it doesn't
work... i can't understand why
I tried cleaning the project but the same happened.
On Dec 13, 2007 11:44 PM, Andy Clement <[EMAIL PROTECTED]> wrote:
> You wouldn't need the cast compiling this java:
>
> interface Ola {}
> class Client implements Ola {
> public void aux() {
> Ola o = new Client();
> }
> }
>
> So you don't need the cast if you pull out the implements into an aspect:
>
> interface Ola {}
> class Client {
> public void aux() {
> Ola o = new Client();
> }
> }
> aspect X {
> declare parents: Client implements Ola;
> }
>
> Since the type hierarchy is entirely consistent for this program once the
> declare parents has been applied.
>
> If you are doing a fresh compile from source, the code above will be
> fine. There are some issues with incremental compilation and interype
> declarations like the declare parents statement - to see if that is what is
> affecting you, do a project clean - does it now compile cleanly?
>
> The only time the above set of declarations wont work together is if you
> compiled pieces of the program separately, for example compiling Ola and
> Client without the aspect - that would require the cast.
>
> Did you try putting the code I included in a source file to see if that
> works for you? What level of AspectJ/AJDT are you on, the latest?
>
> In reply to Bhaskar
>
> > I have seen the type cast error happen to me a couple of times before,
> > I never verified if it was due to the eager parsing by the editor the
> > typecast seemed to make sense to me and I put it in there.
>
> If you are in the AspectJ Editor for the files, that editor is aware of
> intertype declarations. If you see this problem in that case then it may be
> an incremental compilation problem - which, as I mentioned above, we can
> determine by doing a project clean and observing whether the problem
> vanishes.
>
>
> Andy.
>
> On 13/12/2007, Renato Rodrigues <[EMAIL PROTECTED]> wrote:
> >
> > For me it only works if i do the cast Bhaskar Maddala suggested.Is this
> > normal?
> >
> >
> >
> > I'm within an eclipse project so i just save and it compiles alone.
> > Didn't understand your question, sorry.
> >
> > If i defined the aspect like :
> >
> > aspect example{
> >
> > public interface Ola{};
> > declare parents: Client implements Ola;
> >
> > }
> >
> > and still continue with the same code in class Client is it normal that
> > it gives and error saying "Ola cannot be resolved to a type"
> >
> > On Dec 13, 2007 9:06 PM, Andy Clement < [EMAIL PROTECTED]> wrote:
> >
> > > I'm not quite sure what you are doing, but that program compiles fine
> > > for me:
> > >
> > > ---- Client.java ---- 8<----
> > > interface Ola {}
> > >
> > > public class Client {
> > > Client(){};
> > >
> > > public int num1(){
> > > return 1;
> > > }
> > >
> > > public void aux()
> > > {
> > > Ola o = new Client();
> > > }
> > > }
> > >
> > > aspect example{
> > >
> > >
> > > declare parents: Client implements Ola;
> > >
> > > }
> > > ---- Client.java ---- 8<----
> > >
> > > C:\aspectj1.5-dev>ajc -showWeaveInfo Client.java
> > > Extending interface set for type 'Client' (Client.java) to include
> > > 'Ola' (Client.java)
> > >
> > > Are you compiling all from source? are you binary weaving in some way?
> > > it should be fine. You *might* get a eager parsing bug in the eclipse
> > > editor as it isnt aware the aspect will make everything alright at
> > > compile time?
> > >
> > > Andy.
> > >
> > > On 13/12/2007, Renato Rodrigues < [EMAIL PROTECTED]> wrote:
> > >
> > > > Im a newbie to AspectJ and i'm trying to do a simple declare parents
> > > > expression so a Class can implement an interface
> > > >
> > > > i have class:
> > > >
> > > >
> > > > public class Client {
> > > > Client(){};
> > > >
> > > > public int num1(){
> > > > return 1;
> > > > }
> > > >
> > > > public void aux()
> > > > {
> > > > Ola o = new Client();
> > > > }
> > > > }
> > > > and aspect :
> > > >
> > > >
> > > > public aspect example{
> > > >
> > > >
> > > > declare parents: Client implements Ola;
> > > >
> > > > }
> > > >
> > > >
> > > > and the compiler says Type mismatch: cannot convert from Client to
> > > Ola
> > > >
> > > > _______________________________________________
> > > > aspectj-users mailing list
> > > > [email protected]
> > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > >
> > > >
> > > _______________________________________________
> > > aspectj-users mailing list
> > > [email protected]
> > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > >
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users