Bug 318884 - AJDT incremental compile does not update errors in Java files correctly
Summary: AJDT incremental compile does not update errors in Java files correctly
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.9RC1   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: 1.6.10   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-05 08:07 EDT by Peter Hendriks CLA
Modified: 2010-07-19 18:40 EDT (History)
3 users (show)

See Also:


Attachments
Example project to reproduce error (6.10 KB, application/octet-stream)
2010-07-05 08:09 EDT, Peter Hendriks CLA
no flags Details
AJDT event trace corresponding to problems (4.94 KB, text/plain)
2010-07-05 08:16 EDT, Peter Hendriks CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hendriks CLA 2010-07-05 08:07:05 EDT
Build Identifier: Eclipse platform (3.5.2): M20100211-1343 (AJDT: 2.1.0.e35x-release-20100630-1500)

When a Java project is converted to an "AspectJ" project, the default Java builder is replaced with an AJDT enhanced this builder. When Java files are modified, some compile errors are not updated correctly, giving false positives or negatives for the developer (i.e. a warning/error is not shown, or not removed when expected).

Workaround is to clean the project manually to make sure no compile errors are present. This is of course very annoying and error prone, and basically means incremental compilation is broken for AspectJ enabled projects.


Reproducible: Always

Steps to Reproduce:
I've included a sample project, see the attachment.
1. PlainJava depends on JavaClassWithPointsApplied. Open JavaClassWithPointsApplied and add " throws IOException" to publicFoo() method.
2. The problems view/package explorer does NOT show the problem in PlainJava (does not catch IOException).
3. Open PlainJava. The error marker is now shown.

Note that some other operations (removing the method, for instance), does update correctly.
Comment 1 Peter Hendriks CLA 2010-07-05 08:09:25 EDT
Created attachment 173417 [details]
Example project to reproduce error
Comment 2 Peter Hendriks CLA 2010-07-05 08:16:05 EDT
Created attachment 173419 [details]
AJDT event trace corresponding to problems

The AJDT Event trace shows that when adding a checked exception, corresponding files are not considered, resulting in the error. The trace shows that when a method is removed, corresponding files are considered correctly.
Comment 3 Andrew Eisenberg CLA 2010-07-05 09:50:57 EDT
This may be an aspectj issue regarding how file dependencies are stored across incremental compiles.  It may be that when a Java file in another project adds a new exception, this is not marked as a structural change.  And there is no subsequent recompile of dependent source files.
Comment 4 Andrew Clement CLA 2010-07-05 11:43:06 EDT
yes, more likely to be AspectJ than AJDT - reassigning
Comment 5 Peter Hendriks CLA 2010-07-05 15:22:21 EDT
Thanks for the comments, this lead me to do some additional testing.

In summary: the following does not work:

1. Changing throws clause
2. Removing/adding Java class (inner or outer)
3. Changing a generic parameter type on a constructor, method or field. [1]

I tried the following:

class removed/added FAIL
method removed/added PASS
constructor removed/added PASS
class visible/invisible PASS
method visible/invisible PASS
constructor visible/invisible PASS
class static/non-static PASS
method static/non-static PASS
method return type change PASS
method param type change PASS
method generic return type change FAIL [1]
method generic param type change FAIL
constructor generic param type change FAIL
method param added/removed PASS
method throws clause changed FAIL
field added/removed PASS
field visible/invisible PASS
field type change PASS
field generic param type change FAIL
inner class added/removed FAIL
inner class visible/invisible PASS
inner class static/non-static PASS
class generic type param change PASS [2]
method generic type param change PASS

[1] Example: Change from List<String> to List<Long>
[2] Example: Change from class Foo <T extends Number> to <T extends List>
Comment 6 Andrew Clement CLA 2010-07-05 15:35:52 EDT
given that no changes are being made to the aspect, its existence should be irrelevant (if it isn't that is another clue).  Without the aspect we are reduced to pure-java, and AspectJ is based on the eclipse java compiler at heart for java compilation.  This would suggest a problem with the eclipse compiler.  Now AspectJ is based on an old level of the compiler (eclipse 3.3) so some of these things may be issues that exist in the old eclipse compiler that have been fixed since - AspectJ would need to rebase on a new version of the eclipse compiler to pickup their fixes.
Comment 7 Peter Hendriks CLA 2010-07-05 16:47:19 EDT
Although it probably does not matter because it is now classified as an AspectJ bug, I did my last testing run on Eclipse 3.6, no difference from 3.5.2.

We are using AJDT in a vanilla AspectJ setup, I retested this in a Spring Roo project and the problem is the same. Because aspects are happening automagically in Roo this might be even more confusing for Roo users, and makes incremental compilation unreliable there too.

I retested without any aspects, the behavior is the same. Just 2 Java classes in the same project will do.

I also tested with combinations of plain Java (standard JDT compiler) and AspectJ compiler projects. JDT -> AspectJ works fine, the other way around does not work.
Comment 8 Peter Hendriks CLA 2010-07-05 17:20:09 EDT
(In reply to comment #6)
> given that no changes are being made to the aspect, its existence should be
> irrelevant (if it isn't that is another clue).  Without the aspect we are
> reduced to pure-java, and AspectJ is based on the eclipse java compiler at
> heart for java compilation.  This would suggest a problem with the eclipse
> compiler.  Now AspectJ is based on an old level of the compiler (eclipse 3.3)
> so some of these things may be issues that exist in the old eclipse compiler
> that have been fixed since - AspectJ would need to rebase on a new version of
> the eclipse compiler to pickup their fixes.

I have been on Eclipse since 1.0 and never experienced these kind of problems in JDT. To be sure, I downloaded Eclipse 3.3 classic from the archives and tried this in a plain Java project. The problems do not occur there.

Maybe the AspectJ modifications to the compiler introduced these bugs? In that case, rebasing may not resolve the issue. This is just pure speculation on my part, I have no knowledge at all of the AspectJ compiler codebase.
Comment 9 Andrew Clement CLA 2010-07-05 18:19:39 EDT
Yep, I retried on 3.3 too and it didn't fail - so it is the way in which AspectJ is managing the rebuilding.  We do need to upgrade from 3.3 at some point but thankfully we don't have to in order to fix these issues.  The 'bundle' of generics related ones are likely because some incremental handling hasn't been revisited since it was first written for pre-Java5.

> method throws clause changed
fixed
Comment 10 Andrew Clement CLA 2010-07-05 18:51:12 EDT
> method generic return type change
> method generic param type change
> constructor generic param type change
fixed
Comment 11 Andrew Clement CLA 2010-07-05 19:02:46 EDT
> field generic param type change
fixed
Comment 12 Peter Hendriks CLA 2010-07-06 04:14:00 EDT
(In reply to comment #11)
> > field generic param type change
> fixed

Great news! Is there any dev build available to try this on?
Comment 13 Andrew Clement CLA 2010-07-06 10:48:58 EDT
no, not yet.  There are dev builds of AspectJ but none of AJDT that includes that fixed AspectJ.  When everything is addressed I'll look to create one.
Comment 14 Andrew Clement CLA 2010-07-06 15:21:34 EDT
> inner class added/removed
fixed

> class removed/added
fixed

Basically I've fixed everything from your list I could recreate.  Waiting on some AJDT build process changes then we can create an AJDT dev build that includes the fixes.
Comment 15 Peter Hendriks CLA 2010-07-19 16:58:07 EDT
I noticed a new drop on the AJDT dev update site and retested this bug on it. It works great on normal Java projects!

However, our workspace also contains aspectj eclipse plug-in projects. Other projects that depend on these projects (both normal Java and other Eclipse plug-in  projects) are not updated at all by incremental compilation (all scenarios fail). 

This bug is in both dev 20100715 and AJDT 2.1.0 release. It seems another kind of problem. Should I open a new bug on this? I also have test projects and reproduce scenarios.
Comment 16 Andrew Eisenberg CLA 2010-07-19 17:05:29 EDT
(In reply to comment #15)
> This bug is in both dev 20100715 and AJDT 2.1.0 release. It seems another kind
> of problem. Should I open a new bug on this? I also have test projects and
> reproduce scenarios.

Yes, please raise a new bug report for this issue.  It would be great if you could attach the failing projects.
Comment 17 Peter Hendriks CLA 2010-07-19 17:37:57 EDT
(In reply to comment #16)
> (In reply to comment #15)
> > This bug is in both dev 20100715 and AJDT 2.1.0 release. It seems another kind
> > of problem. Should I open a new bug on this? I also have test projects and
> > reproduce scenarios.
> 
> Yes, please raise a new bug report for this issue.  It would be great if you
> could attach the failing projects.

I've opened bug 320331 with test projects and reproduce scenario. If additional information or testing is needed I'll be happy to help!
Comment 18 Andrew Clement CLA 2010-07-19 18:40:38 EDT
fixes are all released for this.