I want to use the aspect to add getter and setter for the private id field. I know how to add a method through an aspect, but how can I access a private identifier?
I want to say that I just need to make the aspect justified. I tried the following code, but this aspect cannot access the id field.
public privileged aspect MyAspect {
public String Item.getId(){
return this.id;
}
Perhaps there would be a reflection of the user, as shown in this blog post: http://blog.m1key.me/2011/05/aop-aspectj-field-access-to-inejct.html
Is reflection the only option or is there a way to do this with AspectJ?
source
share