You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an interceptor is defined as a class annotation, method annotations of
the class which is intercepted are lost.
See the attachments. In Test.java , it has 2 Module classes: one has an
interceptor definition, and another does not.
Run Test.java, you will see the result as the following.
:true
:false
The second result means method annotations are lost.
This is not a problem of guice itself, but rather an issue of the underlying proxy
creation libary cglib:
When you are intercepting method calls to objects, guice uses cglib to create a proxy
for these objects. Cglib again subclasses the object's type and overrides all non
final methods. So when you are calling object.getClass.getMethod() you are actually
getting the method of the dynamically created subtype. As far as I have followed the
cglib mailing list ( http://osdir.com/ml/java.cglib.devel/2006-07/msg00006.html ) no
annotations will be copy from your concrete type to the created subtype for backward
compability reasons (at least for cglib versions 2.x). Only type level annotations
can be accessed from the subtype, if the annotation type is annotated with @java.lang.annotation.Inherited
Simple workaround would look like calling
object.getClass.getSuperclass().getMethod(), which is indead dirty and expensive.
From hiro0107 on May 06, 2007 00:34:11
When an interceptor is defined as a class annotation, method annotations of
the class which is intercepted are lost.
See the attachments. In Test.java , it has 2 Module classes: one has an
interceptor definition, and another does not.
Run Test.java, you will see the result as the following.
:true
:false
The second result means method annotations are lost.
Attachment: gist
MethodAnnon.java
TypeAnnon.java
Test.java
Original issue: http://code.google.com/p/google-guice/issues/detail?id=101
The text was updated successfully, but these errors were encountered: