Bug 169432 - Using @DeclareParents with non-marker interface with interface-satisfying class produces incorrect error
Summary: Using @DeclareParents with non-marker interface with interface-satisfying cla...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 1.5.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-03 09:42 EST by Ramnivas Laddad CLA
Modified: 2007-11-08 04:02 EST (History)
2 users (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 2007-01-03 09:42:30 EST
Per (doc/adk15notebook/ataspectj-itds.html) documentation: "If the interface defines one or more operations, and these are not implemented by the target type, an error will be issued during weaving.".

However, if I use @DeclareParents with a non-marker interface targeted to a class that already includes the needed implementation, the compiler produces an incorrect error ("@DeclareParents: used with a non marker interface and no defaultImpl="..." ).

Here is example setup:
// NonMarkerInterface.java
package test;

public interface NonMarkerInterface {
	public void something();
}

// ClassThatAlreadyIncludeRequiredMethods.java
package test;

public class ClassThatAlreadyIncludeRequiredMethods {
	public void something() {
	}
}

// DeclareParentsForNonMarkerInterfaceToAClassThatAlreadyIncludeRequiredMethods.java

package test;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.DeclareParents;

@Aspect
public class DeclareParentsForNonMarkerInterfaceToAClassThatAlreadyIncludeRequiredMethods {
	@DeclareParents("test.ClassThatAlreadyIncludeRequiredMethods")
	public NonMarkerInterface nmi;
}
Comment 1 Andrew Clement CLA 2007-10-26 05:26:18 EDT
ramnivas - are these impacting spring users?
Comment 2 Ramnivas Laddad CLA 2007-10-29 09:17:03 EDT
(In reply to comment #1)
> ramnivas - are these impacting spring users?
> 

I believe I first saw it in a Spring project.
Comment 3 Andrew Clement CLA 2007-11-08 04:02:57 EST
This is a bit of a change to the current implementation which polices everything up front with the simple rule 'does the interface have methods? if it does, the default impl must be specified'.  Switching things around to support this feature is a question of moving that check to weave time from compile time and then for each type that matches the pattern we have to check if it implements the methods as specified on the interface.  I've implemented it and tried it, and it does work OK. 

Changes committed - there may be issues with visibility of the implementing methods and any use of covariance might cause a problem - but the basics are in.