question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AOP classes don't get the annotations of the superclass

See original GitHub issue

From anthony.muller on May 30, 2008 05:41:03

@ME : I’m quite suprised… I annoted a method @MyAnnotation, in order to intercept calls of this method. My problem is when I instanciate an object which has a such annotation using guice. when i search the annoted method through reflection, and i call isAnnotationPresent(MyAnnotation.class), this method returns false!

@jesse@swank.ca: Under the hood, Guice creates a subclass of TotoImpl in order to perform method interception.

For the most part, this is completely transparent to the developer, but there’s a few consequences. getClass() doesn’t return TotoImpl.class. This constraints how your equals() method must be implemented.

I also expect Serializable won’t interoperate with method interception.

The workaround in this case is to use TotoImpl.class rather than toto.getClass() to introspect on your type.

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=201_

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:17

github_iconTop GitHub Comments

7reactions
Supagoatcommented, Feb 19, 2015

Yeah I’m also a little shocked that this has gone on for 6 years now… I’m trying to add AOP to intercept the methods in a Dropwizard service and this totally kills that idea.

1reaction
ashleyfriezecommented, Nov 11, 2018

I think I’ve fixed this issue by writing a custom method matcher - please see https://codingcraftsman.wordpress.com/2018/11/11/google-guice-aop-with-interface-annotations/ and feedback if it’s a solution for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AOP with custom annotation in Super class doesn't work
Annotation inheritance only works from classes onto subclasses, but only if the annotation type used in the superclass bears the meta annotation ......
Read more >
Predefined Annotation Types - Java™ Tutorials
When the user queries the annotation type and the class has no annotation for this type, the class' superclass is queried for the...
Read more >
Chapter 6. Aspect Oriented Programming with Spring
In Spring AOP, aspects are implemented using regular classes (the schema-based approach) or regular classes annotated with the @Aspect annotation (@AspectJ ...
Read more >
Java Annotations | DigitalOcean
Java Annotations provides information about the code. Java annotations have no direct effect on the code they annotate. In java annotations ...
Read more >
ProGuard Manual: Troubleshooting - Guardsquare
There may not be an easy way to filter them to remove these notes. You could remove the duplicate classes manually from your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found