Bug 254618 - [itds] ITD Overrides method in class...is this correct behavior?
Summary: [itds] ITD Overrides method in class...is this correct behavior?
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-07 12:11 EST by Andrew Eisenberg CLA
Modified: 2013-06-24 11:04 EDT (History)
1 user (show)

See Also:


Attachments
Test project that exhibits this behavior. (3.64 KB, application/octet-stream)
2008-11-07 12:12 EST, Andrew Eisenberg CLA
no flags Details
beginnings of the fix (2.52 KB, patch)
2009-03-03 14:09 EST, Andrew Clement CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2008-11-07 12:11:57 EST
When an ITD method has the same parameters as, but different return type to a method in the class it introduces into, the ITD method overrides the method in the class.  I would have expected there to be an error (such as a duplicate method error), but there is no error.  The ITD method seems to replace the original method.

I am attaching a test project that shows this.  I would have expected a compiler error, but instead the project runs and prints "foo!".
Comment 1 Andrew Eisenberg CLA 2008-11-07 12:12:49 EST
Created attachment 117338 [details]
Test project that exhibits this behavior.
Comment 2 Andrew Clement CLA 2008-11-07 14:19:30 EST
interestin'
Comment 3 Andrew Clement CLA 2008-12-01 14:27:46 EST
err, that project is not the right one for this bug report - it doesn't even have the word 'foo' in it anywhere...

Here is a test program that shows the issue:

public class T {
  int foo() { return 5; }
  
  public static void main(String[] argv) {
    System.out.println(new T().foo());
  }
}

aspect X {
  public String T.foo() { return "abc";}
}

prints "abc".

Methods with the same name, same parameters, but different return values are valid in bytecode but are now allowed during compilation - and result in a Duplicate method error.

AspectJ should indeed police this and stop a user doing it.


Comment 4 Andrew Eisenberg CLA 2008-12-01 14:32:01 EST
Sorry about that!  Thanks for looking into it.
Comment 5 Andrew Clement CLA 2009-03-03 14:09:36 EST
Created attachment 127363 [details]
beginnings of the fix

just a couple of test files and where the change would be needed to police it
Comment 6 Andrew Clement CLA 2013-06-24 11:04:10 EDT
unsetting the target field which is currently set for something already released