Bug 247981 - save on a single file (any type - java source, text file etc.) triggers full project build
Summary: save on a single file (any type - java source, text file etc.) triggers full ...
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-19 10:57 EDT by Jakub Hlavaty CLA
Modified: 2008-10-28 06:46 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Hlavaty CLA 2008-09-19 10:57:32 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1. open a project with multiple java source files (tested on a "Dynamic Web Project" with hundreds of java source files and other resources)
2. the option "build automatically" is on
3. JDK is Java 1.5.0_16
4. open a file of your choice (java source, text file, etc.)
5. change some text (or just make the file "dirty" so you can save it)
6. choose File > Save (or CTRL+s)
7. full build is triggered (as in "clean and compile all source files in the project")


More information:
I'm running Eclipse 3.4, JDK 1.5.0_16, Mylyn, Subclipse, WTP + a few small plugins on Fedora Core 9 kernel version  2.6.26.3-29

I encountered this odd behavior a day ago after using Eclipse 3.4 for a few weeks. No notable prior changes to the system (except maybe upgrading from FC7 to FedoraC9). Tried a new workspace, fresh Eclipse installation, but that didn't help.
Comment 1 Jerome Lanneluc CLA 2008-09-22 05:05:27 EDT
I suspect that one of the extra plugins (other than the SDK) is causing grief. Can you please try to reproduce with a plain SDK?
Comment 2 Jakub Hlavaty CLA 2008-09-25 09:54:49 EDT
I didn't have time to reproduce with a plain SDK as you requested, however the problem is gone now (finally!).

It seems to me that the problem was, that after someone removed a JAR dependency from the project, he forgot to fix some missing imports in a java class (testCase) that was no longer used (so most people didn't have it in their classpath and thus didn't know or care). 

The problems view showed this along with another error - something like "due to unsatisfied dependencies the project could not be built" or some such... I assumed this wouldn't be a problem (I mean I assumed, that one missing import would't prevent the rest of the project from being built) so I let it be - since it was only a single unimportant class / testcase. Apparently Eclipse got this "project wasn't built" error even after a full build and so tried again and again to build it...

Today it finally started to annoy me more than a little, so I fixed the imports and was amazed to see the problem suddenly go away.

I'm not sure whether this is a real bug or not so I'll leave the resolution to you. Anyway thanx for the reply!
Comment 3 Jerome Lanneluc CLA 2008-09-26 09:44:36 EDT
(In reply to comment #2)
That would still be a bug. However I cannot reproduce this behavior. If I save a X.java file in a project that has the following errors:

Description	Resource	Path	Location	Type
The project was not built since its build path is incomplete. Cannot find the class file for p.X. Fix the build path then try building this project	Test		Unknown	Java Problem
The type p.X cannot be resolved. It is indirectly referenced from required .class files	X.java	Test/src	line 5	Java Problem

Next time I save this X.java file, an incremental build occurs, i.e. only this file is recompiled.

It would be great if you could give more information on how to reproduce this.
Comment 4 Kent Johnson CLA 2008-09-30 11:10:30 EDT
Jerome - I don't see how this is a bug.

We detected an invalid classpath & reported the error against the project with 'The project was not built since its build path is incomplete...'

If a user chooses to ignore such an error, then repeated full builds that continue to fail for the exact same reason should be expected.
Comment 5 Jerome Lanneluc CLA 2008-09-30 11:24:54 EDT
(In reply to comment #4)
> Jerome - I don't see how this is a bug.
> 
> We detected an invalid classpath & reported the error against the project with
> 'The project was not built since its build path is incomplete...'
> 
> If a user chooses to ignore such an error, then repeated full builds that
> continue to fail for the exact same reason should be expected.
> 
I thought you would do a full build only if the classpath changed. If the user doesn't change the classpath, why would you do a full build? It will still be broken. Or did I miss something?
Comment 6 Kent Johnson CLA 2008-09-30 12:19:46 EDT
We abort the first full build because the classpath is broken & we cannot find a .class file.

Since we didn't successfully build the project, there is no saved build state & we need to do another full build the next time a build is requested.


We only get out of doing full builds when the classpath error is fixed & the full build is successful.
Comment 7 Jakub Hlavaty CLA 2008-10-01 02:02:50 EDT
The thing is, that the full build is actually carried out every time (we have a large project, so that can take about 5 minutes. From what you wrote ("we abort the first full build") I would expect eclipse not to do the full build in the first place (seeing there's a classpath problem), but it does so every time ANYTHING changes (5 minutes in vain). Sorry if that's the normal behavior...
Comment 8 Jerome Lanneluc CLA 2008-10-01 05:39:06 EDT
(In reply to comment #6)
> We abort the first full build because the classpath is broken & we cannot find
> a .class file.
> 
> Since we didn't successfully build the project, there is no saved build state &
> we need to do another full build the next time a build is requested.
> 
> 
> We only get out of doing full builds when the classpath error is fixed & the
> full build is successful.
> 
I'm not seeing this:
1. Enable builder trace
2. Start a new workspace
3. Create a Java project
4. Add external library org.eclipse.jdt.core_3.5.0.v_914.jar
5. Add the following X.java file in the Java project:
import org.eclipse.jdt.internal.core.DeltaProcessingState;
public class X {
	public void foo(DeltaProcessingState state) {
		state.resourceChanged(null);
	}
}
Observe: You get 2 error markers in the Problems view
6. Make a change to X.java (add a space)
7. Save
Observe: The tracing says it is doing an INCREMENTAL build
Comment 9 Kent Johnson CLA 2008-10-01 09:57:00 EDT
Sorry Jakub, I wasn't clear enough.

Each time a build is invoked, we 'believe' the missing .class file is now available.

Its possible that you've added/replaced one or several jar files, or .class files in a class folder, that could make the build succeed.

As your case shows, it can take us 5 minutes to find out that it still is NOT available AND you still have an indirect reference to it.
Comment 10 Kent Johnson CLA 2008-10-01 11:18:39 EDT
Jerome - you're right. We're no longer doing a 'full' build, but an incremental of all source files in the project.

I forgot about this change in IncrementalImageBuilder on lines 81-85 :

if (this.javaBuilder.hasBuildpathErrors()) {
  // if a mssing class file was detected in the last build, a build state was saved since its no longer fatal
  // but we need to rebuild every source file since problems were not recorded
  // AND to avoid the infinite build scenario if this project is involved in a cycle, see bug 160550
  // we need to avoid unnecessary deltas caused by doing a full build in this case


See bug 160550

I'll add a new debug message for this case.
Comment 11 Kent Johnson CLA 2008-10-03 12:20:19 EDT
Releasd extra debug message for 3.5M3
Comment 12 David Audel CLA 2008-10-28 06:46:54 EDT
Verified for 3.5M3