Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358389 - Incorrect advising in eclipse vs reality
Summary: Incorrect advising in eclipse vs reality
Status: RESOLVED INVALID
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 2.1.3   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 2.1.3   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-21 06:39 EDT by Niklas Lönn CLA
Modified: 2011-09-23 12:10 EDT (History)
1 user (show)

See Also:


Attachments
Screenshot of Main output vs eclipse advices (15.73 KB, image/png)
2011-09-21 06:40 EDT, Niklas Lönn CLA
no flags Details
Eclipse project (3.73 KB, application/x-download)
2011-09-21 06:43 EDT, Niklas Lönn CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niklas Lönn CLA 2011-09-21 06:39:36 EDT
AJDT seems to evaluate advices incorrectly.
It shows too much advices in eclipse, but they are not advised in reality.
This becomes a problem for us, because when our advice handles checked exceptions, we get error markers in eclipse.

I have attached a small test case showing the problem.
Comment 1 Niklas Lönn CLA 2011-09-21 06:40:26 EDT
Created attachment 203749 [details]
Screenshot of Main output vs eclipse advices

Here's a screenshot of the problem
Comment 2 Niklas Lönn CLA 2011-09-21 06:43:19 EDT
Created attachment 203750 [details]
Eclipse project

Didn't find this attachment, so i upload it again, just in case
Comment 3 Andrew Eisenberg CLA 2011-09-23 12:10:01 EDT
I understand the confusion, but this is the expected behavior.  In your example project, notice how there is a '?' in the advice markers.  This means that the application cannot be completely determined at compile time (ie- there is a runtime test).

Look at your pointcut:

pointcut getName(Friend this_) : execution(String getName(..)) && this(this_);

It says that the runtime type of this_ must implement Friend and it must have a getName() method.

Consider this class:

class YesAFriend extends NotAFriend implements Friend { }

For calls to getName() when the instance is of type YesAFriend, this advice will apply.  And that is why there is a runtime test of NotAFriend.getName().