Bug 242044 - add support for joinpoints on cast and instanceof instruction
Summary: add support for joinpoints on cast and instanceof instruction
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-25 02:52 EDT by nicolas de loof CLA
Modified: 2008-07-25 02:52 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.