views:

257

answers:

2

Hi !

Am trying to create an object using an AOP framework which uses CGLIB to create proxy objects. Strangely enough, the "enhanced" proxy object is devoid of ANY annotations the previous class had!

Can anyone tell me how can I make CGLIB retain the annotations on the proxies it creates?

Cheers! Nirav

A: 

This isn't an issue with "retaining" the annotations. CGLIB proxies are actually generated subclasses of the target object's class. These subclasses may not have annotations, but their superclass (i.e. your own class) will still have them. Any annotation-reflecting code you use needs to be able to look back up the class hierarchy to look for annotations.

skaffman
A: 

It's a valid problem (I'm running into now myself) as a) not all frameworks are smart enough to inspect parent classes b) even if they are smart enough, they may chose not to. The latter seems to be the case with Guice. FWIW, https://issues.apache.org/jira/browse/WICKET-1130 is the problem I was working on when I found this out.

Eelco