Bug 214559 - Binary operator with type patterns in declare parents don't work as expected
Summary: Binary operator with type patterns in declare parents don't work as expected
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.4RC1   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 1.6.0 M2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-07 18:27 EST by Ramnivas Laddad CLA
Modified: 2008-02-20 16:08 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.