[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] DeclareMixin with a java API class as the mixin target.


Although you don't say, I presume you are loadtime weaving?  I'm kind
of surprised you are able to touch a java.* type through loadtime
weaving but I guess you must be able to in your setup if advice is
working for you.  Binary weaving would be more reliable for weaving
into that type.  Anyway, I presume you don't get any weaveinfo saying
the declare mixin was able to do its job?  Perhaps run with debug
switched on in the aop.xml, that will enable us to get some
diagnostics on what is happening.


2009/9/5 Nicholas Nguyen <nnguyen@xxxxxxxxxxxxx>:
> Hello,
> I wish to mixin my classes into the Swing classes but I was surprised that
> my code below didn't work: there was a cast exception. I've mixed in to my
> own target class okay so I think it's not my setup issue.
> I'm quite keen for this to work so I was wondering if this is currently
> a limitation or is it possible? I'm using Maven plugin with 1.6.5 rt and
> annotations - I didn't try the direct syntax style yet.
> I wonder if it's caused by order of class loading, but then around advice on
> Container methods proved to work for me.
> with best regards,
> Nic.
> import java.awt.Container;
> import org.aspectj.lang.annotation.Aspect;
> import org.aspectj.lang.annotation.DeclareMixin;
> @Aspect
> public class App
> {
>     @DeclareMixin("java.awt.Container")
>     public Mixin createContainerMixin(){
>                 return new MixinImpl();
>     }
>     public interface Mixin {
>         void baz();
>     }
>     public class MixinImpl implements Mixin {
>         public void baz(){
>                    System.out.println("baz mixed in !");
>         }
>     }
>     public static void main( String[] args )    {
>         Container c = new Container();
>         Mixin ci = (Mixin) c;
>         ci.baz(); // I get class cast exception here.
>     }
> }
> ________________________________
> Use Hotmail to send and receive mail from your different email accounts.
> Find out how.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users