Bug 433351 - Declare parents fails on interfaces on the inpath depending on directory structure
Summary: Declare parents fails on interfaces on the inpath depending on directory stru...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.8.9   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-23 22:43 EDT by Jaime Metcher CLA
Modified: 2016-02-18 15:26 EST (History)
1 user (show)

See Also:


Attachments
testcase (59.27 KB, application/zip)
2014-04-23 22:43 EDT, Jaime Metcher CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaime Metcher CLA 2014-04-23 22:43:15 EDT
A declare parents ITD that extends one interface with another interface is not applied if:

- the new parent interface is supplied on the inpath
- the jar or classes folder specified on the inpath has the package root at the root of the jar or classes folder

See the attached test case.  To run the test case:
- edit the three build*.sh scripts and set AJHOME and PROJHOME appropriately
- make sure you have the right java on the path, or edit the build scripts to invoke the right java
- run test.sh
- inspect the results* files

Then:
proj1/jar/proj1.jar is a jar with a non-package internal structure.  proj1/jar/proj1v2.jar is a jar with an internal structure that follows the package structure.  With AspectJ 1.7, supplying proj1.jar on the inpath results in sucessful weaving of the interface ITD specified in proj2/src/test/extender/Extender.aj, but supplying proj1v2.jar results in no weaving.  With either jar the class ITD is successful.

AspectJ 1.6.10 works for both class and interface ITDs with either input jar.

For example, in result_1.7_fromjar we see:

Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender.aj)

for the first compilation run (lines 1-31), but this message is missing for the second compilation run (lines 32-end)
Comment 1 Jaime Metcher CLA 2014-04-23 22:43:51 EDT
Created attachment 242263 [details]
testcase
Comment 2 Andrew Clement CLA 2014-06-19 12:23:26 EDT
I actually dug into this a bit and distilled out the first of the issues. I have these files (thanks for the test code!):

InterfaceProj1.java
====
package test;

public interface InterfaceProj1<T> {
	public abstract int aMethod();

}
====


Extender.aj
====
package test.extender;
import test.*;

public aspect Extender {
	declare parents: InterfaceProj1 extends InterfaceProj2;
}
====

InterfaceProj2.java
====
package test.extender;

public interface InterfaceProj2<T> {
	public abstract int bMethod();	
}
====

I compile a jar:

ajc -1.5 InterfaceProj1.java -outjar code.jar

I then apply the aspect:

ajc -1.5 -showWeaveInfo Extender.aj InterfaceProj2.java -inpath code.jar -d output

1.6.10 produces:

Extending interface set for type 'test.InterfaceProj1' (InterfaceProj1.java) to include 'test.extender.InterfaceProj2' (Extender.aj)

1.7 does not produce that message, and neither does 1.8.

And this does not happen if InterfaceProj1 is not generic. This pointed me to the problem and I just committed a fix.  I think there are further issues so am continuing to look at it.
Comment 3 Andrew Clement CLA 2014-06-19 19:52:20 EDT
Two more issues came out of the test code. Both related to ordering and whether the weaver was processing ClassProj1 before InterfaceProj1. If it saw ClassProj1 first it would see InterfaceProj1<T> as the super type, process it (badly) and then fail to do the right thing for the real InterfaceProj1 (raw type). I have fixes for these things but they are a bit serious and I don't want to damage 1.8.1 unnecessarily since that release is primarily about improving the java8 support. So I'll stuff them in a branch until i get a chance to revisit (bug433351 branch).
Comment 4 Andrew Clement CLA 2016-02-18 15:26:31 EST
After Jaime reminded me, I've dug up the branch and moved the test cases and fixes from it into the mainline, will be in 1.8.9. I'm still a *little* nervous since it disturbs a key hierarchy weaving algorithm, but these changes pass all the existing tests and the new tests.