Bug 108888

Summary: Load Time Weaving not Interoperating with Build Time Weaving
Product: [Tools] AspectJ Reporter: Ron Bodkin <rbodkin+LISTS>
Component: CompilerAssignee: Alexandre Vasseur <avasseur>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: matthew_webster
Version: DEVELOPMENT   
Target Milestone: 1.5.0 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 104218    
Bug Blocks:    

Description Ron Bodkin CLA 2005-09-06 19:50:03 EDT
Sample input:

public class Main {
    public static void main(String args[]) {}
}

public aspect LoadTime {
    before() : execution(* main(..)) {
        System.out.println("load time weaving: running main");
    }
}

aspect BuildTime {
    before() : execution(* main(..)) {
        System.out.println("running main");
    }
}

In META-INF/aop.xml:
<aspectj>
    <weaver options="-proceedOnError"/>
    <aspects>
        <aspect name="LoadTime"/>
    </aspects>
</aspectj>

ajc -Xreweavable Main.aj BuildTime.aj
ajc LoadTime.aj

Then:
java Main
produces:
running main

java -javaagent:...\aspectjweaver.jar  Main
produces:
load time weaving: running main

So the load-time weaving has rewoven Main and prevented the original advice 
from running.
java
Comment 1 Ron Bodkin CLA 2005-09-06 20:14:08 EDT
Further investigation reveals the following cause for the problem: the 
originally woven aspect isn't listed in the aspects section of the aop.xml 
file. A work-around that fixes the problem is to list the originally woven 
aspect there. I believe that load-time weaving HAS to honor reweavable aspects 
that aren't explicitly listed, rather than (silently!) stripping them out.
Comment 2 Adrian Colyer CLA 2005-09-08 04:14:53 EDT
tagging with M4...
Comment 3 Matthew Webster CLA 2005-09-14 13:01:41 EDT
See bug 104218 which now ensures an error is issued in this situation and bug 
95516 which will esnure the necessary aop.xml file is always generated.
Comment 4 Alexandre Vasseur CLA 2005-09-30 05:55:29 EDT
deps
Comment 5 Alexandre Vasseur CLA 2005-10-24 05:50:25 EDT
closing this one, tracking under 104218 instead

*** This bug has been marked as a duplicate of 104218 ***