Bug 279983 - Generic intertype method does not receive bridge method when overridden
Summary: Generic intertype method does not receive bridge method when overridden
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.6.6   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-11 13:50 EDT by Dave Whittaker CLA
Modified: 2009-07-27 21:52 EDT (History)
1 user (show)

See Also:


Attachments
Testcase (5.38 KB, application/zip)
2009-06-11 13:50 EDT, Dave Whittaker CLA
no flags Details
Patch for weaver module (3.47 KB, patch)
2009-06-11 16:31 EDT, 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 Dave Whittaker CLA 2009-06-11 13:50:08 EDT
Created attachment 138951 [details]
Testcase

Build ID: M20090211-1700

AspectJ 1.6.5

See the attached test case.  When there are two generic intertype methods defined in an aspect, and one calls the other:

	public void SelectAction<I, T>.setSelected(T object){
		//do nothing
	}
	
	public void SelectAction<I, T>.setSelectedId(I id){
		setSelected(null);
	}
	
Then the implementing class overrides the called method:

public class Test implements SelectAction<Long, User>{

	public void setSelected(User user){
		//overriden version
	}
	
	public static void main(String[] args){
		new Test().setSelectedId(1l);
	}
	
}

A call to setSelectedId will result in:

Exception in thread "main" java.lang.AbstractMethodError: Test.setSelected(Ljava/lang/Object;)V
	at SelectActionAspect.ajc$interMethodDispatch1$SelectActionAspect$SelectAction$setSelected(SelectActionAspect.aj)
	at SelectActionAspect.ajc$interMethod$SelectActionAspect$SelectAction$setSelectedId(SelectActionAspect.aj:13)
	at Test.setSelectedId(Test.java:1)
	at Test.setSelectedId(Test.java:1)
	at SelectActionAspect.ajc$interMethodDispatch1$SelectActionAspect$SelectAction$setSelectedId(SelectActionAspect.aj)
	at Test.main(Test.java:13)
Comment 1 Andrew Clement CLA 2009-06-11 16:31:45 EDT
Created attachment 138977 [details]
Patch for weaver module

I can see where the problem is (thanks for the testcase) but it is quite a disruptive fix.  There are 3 problems in there:

- we look at the raw type 'SelectAction' to see if it has intertypes on it.  It doesn't have because they are on the generic type backing the raw type

- once we find those, we only deal with erasures to discover with parameters 'match' - this doesn't allow for plain old methods that just override and are nothing to do with generics (so we have problems with 'T extends Object' and 'User' in this testcase)

- once we are past *that* we mess up looking at the return type

the attached patch causes your test program to pass but breaks some other code.

Due to the disruptive nature of the change, I think I'll wait until 1.6.5 is out and fix this properly in early 1.6.6 builds.
Comment 2 Dave Whittaker CLA 2009-06-11 16:39:02 EDT
Works for me.  In the meantime, if anyone else runs across this issue, the workaround I'm using is to create an abstract superclass, implement the ITD interfaces in that superclass so that the bridge methods are inherited, and then place the overriden method in the subtype.  So the above becomes:

public abstract class AbstractTest implements SelectAction<Long, User>{ }

public class Test extends AbstractTest{

	public void setSelected(User user){
		//overriden version
	}
	
}
Comment 3 Andrew Clement CLA 2009-07-27 21:52:39 EDT
patch reworked and committed.