Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ / AJDT / ajc compilation error with @DeclareMixin

Answered on stack overflow. You need casts in your test class.

Andy

On 23 September 2014 13:52, Eric B <ebenzacar@xxxxxxxxx> wrote:
I'm trying to use @DeclareMixin for the first time, and either I am doing something incorrect, or there is a bug somewhere.

I've published my sample code to github:  https://github.com/benze/AspectJError.git.  I'm pasting the little bits here as well.

If I look at the compiled code of ApplyAspect.class using a decompiler, I can see that ajc has properly added in the implemented interface.
However, the compiler complains in Test that ApplyAspect does not have the setCreated() or the getCreated() methods.

Additionally, if I try to compile the project from the command line, I get compilation errors as well.

I'm not sure what I am doing wrong, or if there is a bug somewhere else with @DeclareMixin directive.


Interface CreatedBean.java:
public interface CreatedBean {
public Object getCreated();
public void setCreated(final Object created);
}


Implementation CreatedBeanImpl.java:
public class CreatedBeanImpl implements CreatedBean{
    private Object created;

    public Object getCreated(){
    return this.created;
    }
   
    public void setCreated(final Object created ){
    this.created = created;
    }
}


Aspect definition:
@Aspect
public class DeclareMixinAspect {
    @DeclareMixin("com.benze.bo.ApplyAspect")
    public CreatedBean auditableBeanMixin(){
        return new CreatedBeanImpl();
    }
}


Class being advised (com.benze.bo pkg):
public class ApplyAspect {
    private String name = "test class";
}


Class trying to use ApplyAspect:
public class Test {

    public static void main(String[] args) {
        ApplyAspect aa = new ApplyAspect();
        aa.setCreated(new Date());
        System.out.println( aa.getCreated().toString());
        System.out.println(aa.toString());
        System.out.println("all done");
    }
}




Thanks,

Eric


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top