Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method anntation lost when interceptor used with class annotation. #101

Closed
gissuebot opened this issue Jul 7, 2014 · 3 comments
Closed

Comments

@gissuebot
Copy link

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

@gissuebot
Copy link
Author

From hiro0107 on May 18, 2007 18:14:32

Let me know,does this behavior seem to be part of the specification?

@gissuebot
Copy link
Author

From sven.linstaedt on June 02, 2008 02:57:28

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.

@gissuebot
Copy link
Author

From limpbizkit on June 08, 2008 16:28:16

This was reported 2x, and issue 201 has more commentary. Closing as duplicate.

Status: Duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant