Guice framework not able to intercept private methods

949 views
Skip to first unread message

sandy

unread,
Jun 20, 2010, 12:57:03 AM6/20/10
to google-guice
I am using Guice with AOP alliance
There is a private method in my class and I have created an method
interceptor for it
but the control doesnt reaches to my interceptor.But when I changed
the accessifier from private to public it works

Same is the case with accessing a class's private variable.I have to
define a getter for all the private fields of a class

Just curios to know, Is this a limitation of Guice framework or there
is a work around for it

Dhanji R. Prasanna

unread,
Jun 20, 2010, 1:13:55 AM6/20/10
to google...@googlegroups.com
That's correct. This is because Java does not provide virtual dispatch for private methods, it is not possible to intercept them. If you declare them at any other scope (package local, public or protected) it will work fine.

Dhanji.


--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.


Reply all
Reply to author
Forward
0 new messages