Skip to main content



      Home
Home » Language IDEs » AspectJ » privileged aspects
privileged aspects [message #45520] Tue, 04 January 2005 15:43 Go to next message
Eclipse UserFriend
I have a privileged aspect that has a around advice for a number of calls.
The calls sometime invoke a method that has package visibility (the
calling class is in a different package)this results in a
java.lang.IlegalAccessError.

I would like to get "around" this with a privileged aspect. The way I
tried to do this is in the privilaged aspects around advice I get the
Target object and method and using java reflection and then try to invoke
the method from the aspect (in the around advice). However I get an
java.lang.IlegalAccessException saying that I cant do this from the class
foo the class foo contains the call to the method with package visibility
(it is not in the same package). I thought I could do this from a
privileged Aspect. Why cant I and is there a workaround?
Re: privileged aspects [message #45579 is a reply to message #45520] Wed, 05 January 2005 04:31 Go to previous messageGo to next message
Eclipse UserFriend
The privileged modifier enables _direct_ access from advice and method
bodies i.e. "target.protectedMethod()" and has no effect on reflective
access. For that you will need to call "setAccessible(true)" on the method
object. BTW AspectJ questions are better placed on the aspect-users
mailing list.

Cheers

Javier Garcia wrote:

> I have a privileged aspect that has a around advice for a number of calls.
> The calls sometime invoke a method that has package visibility (the
> calling class is in a different package)this results in a
> java.lang.IlegalAccessError.

> I would like to get "around" this with a privileged aspect. The way I
> tried to do this is in the privilaged aspects around advice I get the
> Target object and method and using java reflection and then try to invoke
> the method from the aspect (in the around advice). However I get an
> java.lang.IlegalAccessException saying that I cant do this from the class
> foo the class foo contains the call to the method with package visibility
> (it is not in the same package). I thought I could do this from a
> privileged Aspect. Why cant I and is there a workaround?
Re: privileged aspects [message #45957 is a reply to message #45579] Tue, 11 January 2005 15:36 Go to previous message
Eclipse UserFriend
Your suggestion worked great... and yes .... I will use the aspectj
mailing list in the future.

Thanks again,



Matthew Webster wrote:

> The privileged modifier enables _direct_ access from advice and method
> bodies i.e. "target.protectedMethod()" and has no effect on reflective
> access. For that you will need to call "setAccessible(true)" on the method
> object. BTW AspectJ questions are better placed on the aspect-users
> mailing list.

> Cheers

> Javier Garcia wrote:

>> I have a privileged aspect that has a around advice for a number of calls.
>> The calls sometime invoke a method that has package visibility (the
>> calling class is in a different package)this results in a
>> java.lang.IlegalAccessError.

>> I would like to get "around" this with a privileged aspect. The way I
>> tried to do this is in the privilaged aspects around advice I get the
>> Target object and method and using java reflection and then try to invoke
>> the method from the aspect (in the around advice). However I get an
>> java.lang.IlegalAccessException saying that I cant do this from the class
>> foo the class foo contains the call to the method with package visibility
>> (it is not in the same package). I thought I could do this from a
>> privileged Aspect. Why cant I and is there a workaround?
Re: privileged aspects [message #585570 is a reply to message #45520] Wed, 05 January 2005 04:31 Go to previous message
Eclipse UserFriend
The privileged modifier enables _direct_ access from advice and method
bodies i.e. "target.protectedMethod()" and has no effect on reflective
access. For that you will need to call "setAccessible(true)" on the method
object. BTW AspectJ questions are better placed on the aspect-users
mailing list.

Cheers

Javier Garcia wrote:

> I have a privileged aspect that has a around advice for a number of calls.
> The calls sometime invoke a method that has package visibility (the
> calling class is in a different package)this results in a
> java.lang.IlegalAccessError.

> I would like to get "around" this with a privileged aspect. The way I
> tried to do this is in the privilaged aspects around advice I get the
> Target object and method and using java reflection and then try to invoke
> the method from the aspect (in the around advice). However I get an
> java.lang.IlegalAccessException saying that I cant do this from the class
> foo the class foo contains the call to the method with package visibility
> (it is not in the same package). I thought I could do this from a
> privileged Aspect. Why cant I and is there a workaround?
Re: privileged aspects [message #585741 is a reply to message #45579] Tue, 11 January 2005 15:36 Go to previous message
Eclipse UserFriend
Your suggestion worked great... and yes .... I will use the aspectj
mailing list in the future.

Thanks again,



Matthew Webster wrote:

> The privileged modifier enables _direct_ access from advice and method
> bodies i.e. "target.protectedMethod()" and has no effect on reflective
> access. For that you will need to call "setAccessible(true)" on the method
> object. BTW AspectJ questions are better placed on the aspect-users
> mailing list.

> Cheers

> Javier Garcia wrote:

>> I have a privileged aspect that has a around advice for a number of calls.
>> The calls sometime invoke a method that has package visibility (the
>> calling class is in a different package)this results in a
>> java.lang.IlegalAccessError.

>> I would like to get "around" this with a privileged aspect. The way I
>> tried to do this is in the privilaged aspects around advice I get the
>> Target object and method and using java reflection and then try to invoke
>> the method from the aspect (in the around advice). However I get an
>> java.lang.IlegalAccessException saying that I cant do this from the class
>> foo the class foo contains the call to the method with package visibility
>> (it is not in the same package). I thought I could do this from a
>> privileged Aspect. Why cant I and is there a workaround?
Previous Topic:Stable release of AJDT and AspectJ
Next Topic:PointCut and Advice to "new" object
Goto Forum:
  


Current Time: Wed May 07 21:17:11 EDT 2025

Powered by FUDForum. Page generated in 0.08957 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top