Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314130

Summary: [plan] [ltw] [hcr] LTW, Reweaving and Hot Code Replace changes reflected every two saves of files
Product: [Tools] AspectJ Reporter: Martin D'Aloia <martindaloia>
Component: LTWeavingAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: aclement
Version: 1.6.9M2   
Target Milestone: 1.6.9   
Hardware: PC   
OS: Windows XP   
URL: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg12114.html
Whiteboard:
Attachments:
Description Flags
The Eclipse test project that shows the bug none

Description Martin D'Aloia CLA 2010-05-24 11:53:33 EDT
Build Identifier: AspectJ 1.6.9.M2 (Eclipse 3.5.1 Build ID: 20090920-1017)

A full description of the bug is in the AspectJ-Users mail list:
http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg12114.html

While debugging if I change the content of a method (ex. the text of a System.out) and save the file, it wouldn't reflected. But if I save the save file again, this time the changes are reflected. And it repeats on cycles of two saves.
The rare is that when I save and the changes are not reflected, in log appears the next two lines and when I save the file and changes are reflected this lines are not showed:

[AppClassLoader@2bbd86] info processing reweavable type test.weaved.Test: test\weaved\Test.java
[AppClassLoader@2bbd86] info successfully verified type test.aspects.TestAspect exists.  Originates from test\aspects\TestAspect.java

This lines comes from the method processReweavableStateIfPresent(String, BcelObjectType) on the class org.aspectj.weaver.bcel.BcelWeaver

Setting -Xset:overWeaving=true was worst because every time that I save the file that is aspected I get this message from Eclipse in a popup: "Hot code replace failed - Scheme change not implemented" and the changes are never reflected, neither in the first save nor in the second save.

My environment is:
Windows XP SP3 32 bits
Sun Java 1.6.0 Update 19 JDK
Eclipse 3.5.1 Build ID: 20090920-1017
AspectJ 1.6.9 M2 (the same occurs with 1.6.8)
Project: A clean new basis java project that only has this test and AspectJ
Weaver options: -Xreweavable -verbose -showWeaveInfo -debug (and also -Xset:overWeaving=true in some tests)
Using: -javaagent:aspectjweaver-1.6.9.M2.jar

I will attach the test project that I used to isolate and reproduce this bug.

Reproducible: Always

Steps to Reproduce:
1. Import the attached project into Eclipse
2. Run the project with the Main.launch that is in the project root.
3. Modify the method print() in the class test.weaved.Test (ex. uncomment a line)
4. See the console log. The changes are not reflected in the behavior.
5. Modify again the method print() in the class test.weaved.Test (ex. uncomment another line)
6. See the console log. Now the changes are reflected in the behavior.
7. The same occurs whatever you change (obviously with the limits of the Hot Code Replace imposed by the JDK)
Comment 1 Martin D'Aloia CLA 2010-05-24 12:00:10 EDT
Created attachment 169687 [details]
The Eclipse test project that shows the bug
Comment 2 Andrew Clement CLA 2010-05-24 21:04:33 EDT
I'll try out the test project tomorrow.

hotswap with ltw is still not 100% supported - up until recently it was completely banned but a couple of releases ago I removed the restrictions as people had been trying out a patch and with it 'enabled' they seemed to find it was OK (not sure what kinds of change they were making to the file though) - we have no testcases in AspectJ for it, so regressions are certainly possible.

overweaving certainly shouldn't cause a class schema change - so that is interesting.
Comment 3 Andrew Clement CLA 2010-05-26 18:32:34 EDT
as suspected, it was just showing that we are limping along with our hotswap support.  The weaver is not designed to see something for a second time.  I've patched it up to address this case but I'd imagine other scenarios will be lurking.

I don't have a test harness to build a test for a hotswap type case but I've just tried out the fix and it does address the problem you describe.
Comment 4 Martin D'Aloia CLA 2010-06-28 10:03:47 EDT
For the record:

Finally I tested this with the 1.6.9.RC1 version and I can confirm that now works fine in every save. Also now works too with -Xset:overWeaving=true

Great work!
Thanks Andy