Community
Participate
Working Groups
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!".
Created attachment 117338 [details] Test project that exhibits this behavior.
interestin'
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.
Sorry about that! Thanks for looking into it.
Created attachment 127363 [details] beginnings of the fix just a couple of test files and where the change would be needed to police it
unsetting the target field which is currently set for something already released