Bug 214559

Summary: Binary operator with type patterns in declare parents don't work as expected
Product: [Tools] AspectJ Reporter: Ramnivas Laddad <ramnivas>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: aclement
Version: 1.5.4RC1   
Target Milestone: 1.6.0 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ramnivas Laddad CLA 2008-01-07 18:27:19 EST
Found this problem while fixing a bug related to @Configurable support in Spring.

If I use type pattern based on an interface introduced through 'declare parents' and then combine type pattern for that interface with other type pattern in another 'declare parents', it doesn't work (the second parent doesn't get introduced). Here is a test case that illustrates the problem:

package test;

import junit.framework.TestCase;

public class DeclareParentPrecedenceTest extends TestCase {
	public void testParenting() {
		TestClass testObject = new TestClass();

		assertTrue(testObject instanceof Interface1); // pass
		assertTrue(testObject instanceof Interface1TestClass); // fail
	}
}

aspect TestAspect  {
	declare parents: 
		TestClass implements Interface1;

	declare parents: 
		TestClass && Interface1+ implements Interface1TestClass;
}

interface Interface1 {
}

interface Interface1TestClass {
}

class TestClass {
}

Interestingly enough:
1. If either TestClass or Interface1 is removed in the second 'declare parents' the test works.
2. If TestClass implements Interface1 directly (not through 'declare parents'), the test works.
Comment 1 Andrew Clement CLA 2008-02-20 16:08:52 EST
Took me a while to get this to fail - it depends on the order in which the weaver chooses to apply the declare parents.  Although the code is intended to loop around repeatedly applying them until a steady state is reached, this test showed a case that didn't work.

fix committed.