[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] pointcut to intercept "instanceof" instruction ?



I'd like to define an Aspect to detect use of "instanceOf" instruction in my business domain code.
As I'm using Hibernate, the abstract @Entity class "Pet" cannot be casted to its child "Cat" due to Hibernate proxies :

Pet felix = ....;
if (felix instanceOf Cat) { // will always be false
    Cat cat = (Cat) felix;  // will fail anyway

To avoid such error in code, I'd like to create an aspect to detect use of instanceOf with a class that is annotated with @Entity.

As I'm not an aspectJ pointcut _expression_ guru, I'd welcome any help ;-)