Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326326 - Incremental Build fails if there are 2 identical classes on classpath
Summary: Incremental Build fails if there are 2 identical classes on classpath
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 major with 1 vote (vote)
Target Milestone: 4.13 M1   Edit
Assignee: Stephan Herrmann CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-27 12:30 EDT by Dmitriy CLA
Modified: 2019-07-10 00:50 EDT (History)
7 users (show)

See Also:


Attachments
attached projects (5.42 KB, application/zip)
2010-09-29 02:13 EDT, Ayushman Jain CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitriy CLA 2010-09-27 12:30:43 EDT
Build Identifier: 20100617-1415

Having 2 identical classes in different projects in the same workspace, breaks the incremental build.  Apparently, when 1 class in 1 project compiles, it forces the other project(s) to recompile as well.  Even changing (w/o saving) a resource, causes the full build of the workspace.
ALL the projects in the workspace are recompiled as well.  So, if there is an independent project 3 in the workspace, it will get recompiled as well.

The only way to ameliorate it is to uncheck "Rebuild class files modified by others" in Window->Preferences->Java->Compiler->Building



Reproducible: Always

Steps to Reproduce:
1. create 2 projects compiling into 1 output location.
Both projects will have an identical class: say com.eclipse.TestClass.

2. In settings, Window->Preferences->Java->Compiler->Building, uncheck "Scrub output folders when cleaning projects" and check "Rebuild class files modified by others" under Output folder section.  Make sure the projects' use this global configuration.

3. Also, make sure Build Automatically is checked under Project menu.

4. Now, you should see that changing any file results in full build of the workspace.  Saving a mod to a java class also results in full build.

Starting eclipse in debug mode, you might see something like following:
----------------------------------------------------------
Finished build of <PROJECT> @ <DATE>

Starting build of <PROJECT 1> @ <DATE>
Found source delta for: <PROJECT 1> 
Found binary delta for: <PROJECT 2>
Clearing last state : State for <PROJECT 1> (#0 @ <DATE>)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file com/eclipse/TestClass
Performing full build since incremental build failed
Clearing last state : State for <PROJECT 1> (#0 @ <DATE>)
FULL build
----------------------------------------
Comment 1 Dmitriy CLA 2010-09-27 12:32:38 EDT
This did not happen in eclipse prior to Helios.
Comment 2 Stephan Herrmann CLA 2010-09-28 04:39:19 EDT
(In reply to comment #0)
> Steps to Reproduce:
> 1. create 2 projects compiling into 1 output location.

Hm, I've never seen that before. Out of curiosity: What advantage 
do you get from compiling both projects into the same output location?
Comment 3 Ayushman Jain CLA 2010-09-28 05:51:29 EDT
(In reply to comment #0)
>[..]
> Steps to Reproduce:
> 1. create 2 projects compiling into 1 output location.

How did you do this exactly? Can you break it down to the exact steps you followed? Thanks.
Comment 4 Dmitriy CLA 2010-09-29 00:40:48 EDT
(In reply to comment #2)
> (In reply to comment #0)
> > Steps to Reproduce:
> > 1. create 2 projects compiling into 1 output location.
> 
> Hm, I've never seen that before. Out of curiosity: What advantage 
> do you get from compiling both projects into the same output location?

The only advantage so far is to reuse the code by making it more modular.
So, if there is a utility project, other projects may be dependent on it.

We used to have 1 large project, but now we are in the process of breaking it up.
Apparently some classes got duplicated in several projects.
Comment 5 Dmitriy CLA 2010-09-29 00:53:48 EDT
(In reply to comment #3)
> (In reply to comment #0)
> >[..]
> > Steps to Reproduce:
> > 1. create 2 projects compiling into 1 output location.
> 
> How did you do this exactly? Can you break it down to the exact steps you
> followed? Thanks.

See my description of how to reproduce this.
Only #1 of my steps seems to need more details.
In the project's properties, you can go to Java Build Pat -> Source.
Check Allow output folders for source folders.
Under project src, select Output folder and press Edit button.
In the new window select radio "Specific output folder" and
hit Browse. Press Create New Folder in the new window to create a folder in the project.  
Give that folder a name (eg. "target") and click Advanced.  In the new window you can link the "target" folder to any folder on the file system.

You can do these steps for several projects to make them compile into 1 place/folder.
Comment 6 Dmitriy CLA 2010-09-29 00:56:10 EDT
(In reply to comment #4)
> (In reply to comment #2)
> > (In reply to comment #0)
> > > Steps to Reproduce:
> > > 1. create 2 projects compiling into 1 output location.
> > 
> > Hm, I've never seen that before. Out of curiosity: What advantage 
> > do you get from compiling both projects into the same output location?
> 
> The only advantage so far is to reuse the code by making it more modular.
> So, if there is a utility project, other projects may be dependent on it.
> 
> We used to have 1 large project, but now we are in the process of breaking it
> up.
> Apparently some classes got duplicated in several projects.

We store projects separately but compile them into Tomcat's Web-INF/classes directory.  Not all projects are built by a developer.
However developers may share some base projects: eg. "utility".
Comment 7 Ayushman Jain CLA 2010-09-29 02:13:46 EDT
Created attachment 179807 [details]
attached projects

Thanks for the detailed steps. I tried to reproduce using the steps on the attached project here with latest I build (I20100922-0800), but couldn't. Can you please check if you still get the problem on the new I build? Or perhaps use the attached project and see if i'm missing something. It has two duplicate classes - ABC and DupClass. I have these two in my workspace plus the sources for jdt core plugin. Making any changes doesn't trigger the full build.
Comment 8 Dmitriy CLA 2010-09-29 12:56:03 EDT
(In reply to comment #7)
> Created an attachment (id=179807) [details]
> attached projects
> 
> Thanks for the detailed steps. I tried to reproduce using the steps on the
> attached project here with latest I build (I20100922-0800), but couldn't. Can
> you please check if you still get the problem on the new I build? Or perhaps
> use the attached project and see if i'm missing something. It has two duplicate
> classes - ABC and DupClass. I have these two in my workspace plus the sources
> for jdt core plugin. Making any changes doesn't trigger the full build.

Very good Ayushman!
I created another workspace with Both projects A and B.
Also
1. I did step 2 in my description:
"Window->Preferences->Java->Compiler->Building, uncheck "Scrub
output folders when cleaning projects" and check "Rebuild class files modified
by others" under Output folder section.  Make sure the projects' use this
global configuration."

2.  I started eclipse in debug mode:
C:\eclipse\eclipse.exe -debug c:\temp\eclipse_start.options -vm "C:\Program Files (x86)\Java\jdk1.6.0_20\jre\bin\java.exe"

c:\temp\eclipse_start.options file contains the following:
# Turn on debug tracing for org.eclipse.jdt.core plugin
org.eclipse.jdt.core/debug=true
# Reports incremental builder activity : nature of build, built state reading, indictment process
org.eclipse.jdt.core/debug/builder=true

You should see an extra Eclipse debug window.

Here is the debug output I am seeing on changing and saving ABC.java:
----------
Starting build of A @ Wed Sep 29 11:33:24 CDT 2010
Found source delta for: A
Clearing last state : State for A (#0 @ Wed Sep 29 11:30:00 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for A (#0 @ Wed Sep 29 11:30:00 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file ABC.class
Recording new state : State for A (#0 @ Wed Sep 29 11:33:24 CDT 2010)
Finished build of A @ Wed Sep 29 11:33:25 CDT 2010

Starting build of B @ Wed Sep 29 11:33:25 CDT 2010
Found source delta for: B
Clearing last state : State for B (#0 @ Wed Sep 29 11:30:00 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for B (#0 @ Wed Sep 29 11:30:00 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/p/A.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file A.class
Writing changed class file ABC.class
Recording new state : State for B (#0 @ Wed Sep 29 11:33:25 CDT 2010)
Finished build of B @ Wed Sep 29 11:33:25 CDT 2010


If I just change ABC but do not save it, I get the same message but with a slight time delay.  So, any change in such a project triggers a FULL build.
That was not happening before Helios.
Comment 9 Dmitriy CLA 2010-09-29 13:08:12 EDT
(In reply to comment #7)
> Created an attachment (id=179807) [details]
> attached projects
> 
> Thanks for the detailed steps. I tried to reproduce using the steps on the
> attached project here with latest I build (I20100922-0800), but couldn't. Can
> you please check if you still get the problem on the new I build? Or perhaps
> use the attached project and see if i'm missing something. It has two duplicate
> classes - ABC and DupClass. I have these two in my workspace plus the sources
> for jdt core plugin. Making any changes doesn't trigger the full build.

One more thing,  If I do not save the file (ABC.java) and keep it like that opened in the workspace, Full build seems to be triggered every 5 min automatically.

Here is the debug log:

Starting build of A @ Wed Sep 29 11:55:01 CDT 2010
Found source delta for: A
Clearing last state : State for A (#0 @ Wed Sep 29 11:54:26 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for A (#0 @ Wed Sep 29 11:54:26 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file ABC.class
Recording new state : State for A (#0 @ Wed Sep 29 11:55:01 CDT 2010)
Finished build of A @ Wed Sep 29 11:55:01 CDT 2010

Starting build of B @ Wed Sep 29 11:55:01 CDT 2010
Found source delta for: B
Clearing last state : State for B (#0 @ Wed Sep 29 11:54:26 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for B (#0 @ Wed Sep 29 11:54:26 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/p/A.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file A.class
Writing changed class file ABC.class
Recording new state : State for B (#0 @ Wed Sep 29 11:55:01 CDT 2010)
Finished build of B @ Wed Sep 29 11:55:01 CDT 2010

Starting build of A @ Wed Sep 29 12:00:02 CDT 2010
Found source delta for: A
Clearing last state : State for A (#0 @ Wed Sep 29 11:55:01 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for A (#0 @ Wed Sep 29 11:55:01 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file ABC.class
Recording new state : State for A (#0 @ Wed Sep 29 12:00:02 CDT 2010)
Finished build of A @ Wed Sep 29 12:00:02 CDT 2010

Starting build of B @ Wed Sep 29 12:00:02 CDT 2010
Found source delta for: B
Clearing last state : State for B (#0 @ Wed Sep 29 11:55:01 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for B (#0 @ Wed Sep 29 11:55:01 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/p/A.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file A.class
Writing changed class file ABC.class
Recording new state : State for B (#0 @ Wed Sep 29 12:00:02 CDT 2010)
Finished build of B @ Wed Sep 29 12:00:02 CDT 2010

Starting build of A @ Wed Sep 29 12:05:02 CDT 2010
Found source delta for: A
Clearing last state : State for A (#0 @ Wed Sep 29 12:00:02 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for A (#0 @ Wed Sep 29 12:00:02 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file ABC.class
Recording new state : State for A (#0 @ Wed Sep 29 12:05:02 CDT 2010)
Finished build of A @ Wed Sep 29 12:05:02 CDT 2010

Starting build of B @ Wed Sep 29 12:05:02 CDT 2010
Found source delta for: B
Clearing last state : State for B (#0 @ Wed Sep 29 12:00:02 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for B (#0 @ Wed Sep 29 12:00:02 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/p/A.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file A.class
Writing changed class file ABC.class
Recording new state : State for B (#0 @ Wed Sep 29 12:05:02 CDT 2010)
Finished build of B @ Wed Sep 29 12:05:02 CDT 2010
Comment 10 Ayushman Jain CLA 2010-09-30 02:17:53 EDT
Dmitriy, whilst i agree that a full build is being triggered for projects A and B, what i was trying to figure out is the validity of your claim - "ALL the projects in the workspace are recompiled as well.  So, if there is an
independent project 3 in the workspace, it will get recompiled as well." Your debug outputs till now and also my investigation confirms that this is not true. The reason for the full build being triggered for A and B may be because they both have a class with the same name, and the resulting class file for both gets compiled into the same folder. This combined with the option "Rebuild class files modified by others" must be triggering the full build. This may be correct behaviour.

Srikanth, what do you think?
Comment 11 Dmitriy CLA 2010-09-30 11:51:51 EDT
(In reply to comment #10)
> Dmitriy, whilst i agree that a full build is being triggered for projects A and
> B, what i was trying to figure out is the validity of your claim - "ALL the
> projects in the workspace are recompiled as well.  So, if there is an
> independent project 3 in the workspace, it will get recompiled as well." Your
> debug outputs till now and also my investigation confirms that this is not
> true. The reason for the full build being triggered for A and B may be because
> they both have a class with the same name, and the resulting class file for
> both gets compiled into the same folder. This combined with the option "Rebuild
> class files modified by others" must be triggering the full build. This may be
> correct behaviour.
> 
> Srikanth, what do you think?

I introduced another project C with class O.java in the package p in this same workspace).  After I change class O, I am seeing full build for all the projects with collisions:

Starting build of A @ Thu Sep 30 10:35:57 CDT 2010
Found source delta for: A
Clearing last state : State for A (#0 @ Thu Sep 30 10:34:54 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for A (#0 @ Thu Sep 30 10:34:54 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file ABC.class
Recording new state : State for A (#0 @ Thu Sep 30 10:35:57 CDT 2010)
Finished build of A @ Thu Sep 30 10:35:57 CDT 2010

Starting build of B @ Thu Sep 30 10:35:57 CDT 2010
Found source delta for: B
Clearing last state : State for B (#0 @ Thu Sep 30 10:34:54 CDT 2010)
INCREMENTAL build
MUST DO FULL BUILD. Found change to class file ABC
Performing full build since incremental build failed
Clearing last state : State for B (#0 @ Thu Sep 30 10:34:54 CDT 2010)
FULL build
About to compile src/p/DupClass.java
About to compile src/p/A.java
About to compile src/ABC.java
Writing changed class file DupClass.class
Writing changed class file A.class
Writing changed class file ABC.class
Recording new state : State for B (#0 @ Thu Sep 30 10:35:57 CDT 2010)
Finished build of B @ Thu Sep 30 10:35:57 CDT 2010

Starting build of C @ Thu Sep 30 10:35:57 CDT 2010
Found source delta for: C
Clearing last state : State for C (#4 @ Thu Sep 30 10:34:07 CDT 2010)
INCREMENTAL build
Compile this changed source file src/p/O.java
About to compile src/p/O.java
Writing changed class file O.class
Recording new state : State for C (#5 @ Thu Sep 30 10:34:07 CDT 2010)
Finished build of C @ Thu Sep 30 10:35:57 CDT 2010
_____________________________

This seems wasteful: we don't want a full build of projects with collisions on any resource change.  This is still (NOT?) working in eclipse before Helios.
Let me know if going forward this is going to be the expected behavior.
Comment 12 Olivier Thomann CLA 2010-09-30 11:53:53 EDT
Why do you have twice the same class in two projects ?
Comment 13 Ayushman Jain CLA 2010-09-30 12:28:23 EDT
(In reply to comment #11)
[..]
> I introduced another project C with class O.java in the package p in this same
> workspace).  After I change class O, I am seeing full build for all the
> projects with collisions:

Wrong observation once again. Only A and B are fully build. Incremental build is successful for C. See your own console output below:

> Starting build of C @ Thu Sep 30 10:35:57 CDT 2010
> Found source delta for: C
> Clearing last state : State for C (#4 @ Thu Sep 30 10:34:07 CDT 2010)
> INCREMENTAL build
> Compile this changed source file src/p/O.java
> About to compile src/p/O.java
> Writing changed class file O.class
> Recording new state : State for C (#5 @ Thu Sep 30 10:34:07 CDT 2010)
> Finished build of C @ Thu Sep 30 10:35:57 CDT 2010

Hence we can atleast conclude that only the projects having the same class, compiling into the same folder are fully build.
Comment 14 Eclipse Genie CLA 2019-06-10 18:02:36 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 15 Stephan Herrmann CLA 2019-06-10 18:18:43 EDT
According to comment 4 the whole scenario seems to be driven by an attempt to fake a project dependency in some weird way.

Whichever way you look at it, compiling two classes to the same location will always give unreliable results.

Unless I'm missing s.t. essential this is a WONTFIX.
Comment 16 Manoj N Palat CLA 2019-07-10 00:50:53 EDT
Verified for Eclipse 4.13 M1 with Build id: I20190709-1800
[nothing to verify]