Bug 242044

Summary: add support for joinpoints on cast and instanceof instruction
Product: [Tools] AspectJ Reporter: nicolas de loof <nicolas.deloof>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description nicolas de loof CLA 2008-07-25 02:52:58 EDT
Use case : 
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, and also to detect a cast to an @Entity annotated type.

Such joinpoint cannot be expressed with aspectj pointcut syntax (AFAIK). Please improve the grammar and compiler to support this use case.