Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Cannot access private field/method declared via ITD from target class

From what I recall the visibility is expressed with respect to the aspect - so indeed the class can’t see it. I don’t *think* that used to work.

This is from a time I think when we were more purist about aspects - and perhaps it is being a bit too strict these days - when what you really want to do is add a new private field to a type, you can’t.
Perhaps there is another visibility to be expressed ‘private to the target and the aspect’ (private shared?). 

Cheers,
Andy

> On Apr 26, 2020, at 6:10 PM, Alexander Kriegisch <alexander@xxxxxxxxxxxxxx> wrote:
> 
> Hi Andy.
> 
> I might remember wrong, but I think this used to work at some point in
> the past, or at least it should. But before I file a Bugzilla ticket, I
> would like to have your opinion, Andy. Declaring something like
> 
> private int MyClass.myField = 0;
> 
> private int Account.getMyField() {
>  return myField;
> }
> 
> basically works and the aspect itself can access the field and the
> method. But the class they are declared on cannot and Ajc says:
> 
> [error] The method getMyField() from the type MyClass is not visible
> 
> For a full MCVE which you can just copy & paste and for my other
> findings, please see my answer here:
> 
> https://stackoverflow.com/a/61450184/1082681
> 
> Kind regards
> -- 
> Alexander Kriegisch
> https://scrum-master.de
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/aspectj-users



Back to the top