Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358389

Summary: Incorrect advising in eclipse vs reality
Product: [Tools] AJDT Reporter: Niklas Lönn <niklas.lonn>
Component: CoreAssignee: AJDT-inbox <AJDT-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: major    
Priority: P3 CC: andrew.eisenberg
Version: 2.1.3   
Target Milestone: 2.1.3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Screenshot of Main output vs eclipse advices
none
Eclipse project none

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().