[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Progress on privileged support for annotation style aspects...
|
One of the benefits of using annotation style aspects is that the
aspect classes can all be compiled with a standard Java compiler
before being passed to an aspect weaver. This is extremely useful in
some situations. But the downside is that Java compilation rules
cannot be subverted in the same way that we can do it in ajc.
So, the only way we can add this kind of privileged access to the
compiler would be through the JCP. However, I believe it would be
difficult to convince many people to go along with it because it
violates accessibility rules, one of the fundamental precepts of Java.
In AspectJ, this violation is considered OK, but only if used with
care under the privileged keyword. I don't want to dismiss your idea,
but I think it would be hard to move this philosophy to another
language.
--a
On Tue, Jan 27, 2009 at 7:44 AM, Neale Upstone <neale.upstone@xxxxxxxxxx> wrote:
> Hi,
>
>
>
> Has any progress been made on solving the issues of privileged access to
> aspects?
>
>
>
> For example, if I have a class:
>
> public class A {
>
> private int i;
>
> }
>
>
>
> and aspect:
>
>
>
> @Aspect
>
> public class AspectA {
>
>
>
> // set i after constructor has returned
>
> @AfterReturning("this(a) && execution(public *.new(..))")
>
> public void setI( A a ){
>
> a.i = 42;
>
> }
>
> }
>
>
>
> then we will get a 'not visible' error for the assignment to i.
>
>
>
>
>
> It seems to me that it would be generally useful, outside of AspectJ too, to
> be able to tell the compiler/editor to allow access to private, protected
> and package scope objects.
>
>
>
> This would be done by changing the function to:
>
>
>
> public void setI( @PrivilegedAccess('private') A a ){
>
> a.i = 42;
>
> }
>
>
>
>
>
> In fact, this would probably equate to an annotation-based 'friend'
> capability that C++ boasts of.
>
>
>
> Naturally, the passing of references would have to be dealt with, but this
> should be possible. It may also allow annotations and an APT plugin to be
> used rather than having to work around security when doing reflection on
> object graphs, for example.
>
>
>
> The benefit of standardising something like this is that it would (with
> agreement with Sun et al) allow a standard compiler to support this. The
> consequences, however, may be rather too scary!
>
>
>
> Cheers,
>
>
>
> Neale
>
>
>
>
>
> **********************************************************************
> IMPORTANT NOTICE.
> Confidentiality: This e-mail and its attachments are intended for the above
> named only and may be confidential. If they have come to you in error you
> must take no action based on them, nor must you copy or show them to anyone;
> please reply to this e-mail and highlight the error.
> Security Warning: Please note that this e-mail has been created in the
> knowledge that Internet e-mail is not a 100% secure communications medium.
> We advise that you understand and observe this lack of security when
> e-mailing us.
> Viruses: Although we have taken steps to ensure that this e-mail and
> attachments are free from any virus, we advise that in keeping with good
> computing practice the recipient should ensure they are actually virus free.
> Monitoring and Scanning: Cambridge Cognition has monitoring and scanning
> systems in place in relation to emails sent and received to: monitor /
> record business communications; prevent and detect crime; investigate the
> use of the Company's internal and external email system; and provide
> evidence of compliance with business practices.
>
> Cambridge Cognition Limited
> Company Registration Number 4338746
> Registered address:
> Tunbridge Court
> Tunbridge Lane
> Bottisham
> Cambridge
> CB25 9TU
> UK
> **********************************************************************
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>