Bug 314130 - [plan] [ltw] [hcr] LTW, Reweaving and Hot Code Replace changes reflected every two saves of files
Summary: [plan] [ltw] [hcr] LTW, Reweaving and Hot Code Replace changes reflected ever...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: 1.6.9M2   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 1.6.9   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL: http://dev.eclipse.org/mhonarc/lists/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-24 11:53 EDT by Martin D'Aloia CLA
Modified: 2010-06-28 10:03 EDT (History)
1 user (show)

See Also:


Attachments
The Eclipse test project that shows the bug (1.56 MB, application/zip)
2010-05-24 12:00 EDT, Martin D'Aloia CLA
no flags Details

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