Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Anonymous classes unaware of introductions into abstract classes



Marius,

I think you have some sort of configuaration problem: "error can't find
type $Local$" concerns me. We can build you example on Windows and Linux at
the command line and in Eclipse. Please check "CLASSPATH" etc.

BTW if you just compile ConcreteClassA.java you won't get woven hence the
error.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/


"Marius M." <marin_marius@xxxxxxxxx>@eclipse.org on 08/10/2004 14:31:59

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    aspectj-users@xxxxxxxxxxx
cc:
Subject:    Re: [aspectj-users] Anonymous classes unaware of introductions
       into abstract classes


Matthew,

Here is the error:


$ ajc -version
AspectJ Compiler 1.2 built on Friday May 21, 2004 at
15:06:22 GMT
$ ajc ConcreteClassA.java
error can't find type $Local$

/home/marin/tests/ConcreteClassA.java:18 error Class
must implement the inherited abstract method
InterfaceA.a2()
InterfaceA a = new AbstractClassA() {
                   ^^^^^^^^^^^^^

2 errors
--------

If you comment out the body of someMethod() (the
anonymous class), it compiles without errors.

-- Marius

P.S. For Eclipse, too ..


--- Matthew Webster <matthew_webster@xxxxxxxxxx>
wrote:

>
>
>
>
> Marius,
>
> My mistake. However your example compiles with
> AspectJ 1.2 and AJDT 1.1.12.
> What errors do you get?
>
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139
> (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB,
> matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/
>
>
> "Marius M." <marin_marius@xxxxxxxxx>@eclipse.org on
> 08/10/2004 12:51:27
>
> Please respond to aspectj-users@xxxxxxxxxxx
>
> Sent by:    aspectj-users-admin@xxxxxxxxxxx
>
>
> To:    aspectj-users@xxxxxxxxxxx
> cc:
> Subject:    Re: [aspectj-users] Anonymous classes
> unaware of introductions
>        into abstract classes
>
>
> Matthew,
>
> Perhaps I miss something, but I doubt it is the
> "declare parents" statement. AbstractClassA
> implements
> InterfaceA already - the "declare parents" does not
> add anything new, imo. Moreover, the introduction
> works for the concrete, named class
> (ConcreteClassA),
> which extends AbstractClassA (note: the previous
> version of the compiler reported errors for the
> concrete class, too. The version 1.2 works fine.).
> Thus, it's only the anonymous class that is unaware
> of
> introduction.
>
> BTW: does your aspect solution work for you?
>
>
> Marius
>
>
> --- Matthew Webster <matthew_webster@xxxxxxxxxx>
> wrote:
>
> >
> >
> >
> >
> > Marius,
> >
> > You are missing something. Although you have an
> > inter-type declared method
> > for "a2()" on AbstractClassA the statement
> > "AbstractClassA is a InterfaceA"
> > is not true hence the compiler error:
> >
> >       Type mismatch: cannot convert from
> <anonymous
> > subclass of
> > AbstractClassA> to InterfaceA
> >
> > You also need a declare parents statement:
> >
> > public aspect IntroAspectA {
> >
> >       declare parents : AbstractClassA implements
> > InterfaceA;
> >
> >       public void AbstractClassA.a2() {
> >
> System.out.println("AbstractClassA.a2()
> > from IntroAspectA");
> >       }
> > }
> >
> > Matthew Webster
> > AOSD Project
> > Java Technology Centre, MP146
> > IBM Hursley Park, Winchester,  SO21 2JN, England
> > Telephone: +44 196 2816139 (external) 246139
> > (internal)
> > Email: Matthew Webster/UK/IBM @ IBMGB,
> > matthew_webster@xxxxxxxxxx
> > http://w3.hursley.ibm.com/~websterm/
> >
> >
> > "Marius M." <marin_marius@xxxxxxxxx>@eclipse.org
> on
> > 07/10/2004 13:21:06
> >
> > Please respond to aspectj-users@xxxxxxxxxxx
> >
> > Sent by:    aspectj-users-admin@xxxxxxxxxxx
> >
> >
> > To:    aspectj-users@xxxxxxxxxxx
> > cc:
> > Subject:    [aspectj-users] Anonymous classes
> > unaware of introductions into
> >        abstract classes
> >
> >
> > Hello,
> >
> >
> >  I couldn't find this problem reported as a bug,
> but
> > I think it is a
> >  compiler bug. It seems that anonymous classes are
> > not able to "see" the
> >  methods introduced by aspects into abstract
> > classes.
> >
> >
> >  Apparently, the previous version of the ajc
> > compiler had this problem for
> >  concrete classes as well, but it was fixed in
> > aspectj 1.2. Yet, it doesn't
> >  work for anonymous classes:
> >
> >
> >
> >
> >
> >  interface InterfaceA {
> >
> >
> >   public void a1();
> >
> >   public void a2();
> >
> >  }
> >
> >
> >  abstract class AbstractClassA implements
> InterfaceA
> > {
> >
> >
> >   public void a1() {
> >    System.out.println("AbstractClassA.a()");
> >   }
> >
> >  }
> >
> >
> >
> >  public class ConcreteClassA extends
> AbstractClassA
> > {
> >
> >
> >   public void someMethod() {
> >    InterfaceA a = new AbstractClassA() {
> >    };
> >   }
> >
> >  }
> >
> >
> >  aspect IntroAspectA {
> >
> >
> >   public void AbstractClassA.a2() {
> >    System.out.println("AbstractClassA.a2() from
> > IntroAspectA");
> >   }
> >  }
> >
> >
> >
> >
> >
> >  The compiler will complain about the anonymous
> > class as not having
> >  implemented the method a2(). However, it will
> work
> > if the AbstractClassA
> >  is not abstract (or if the class is not anonymous
> > :-)).
> >
> >
> >
> >
>
=== message truncated ===




__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users





Back to the top