Bug 20614 - Failure compiling a project with cyclic dependencies
Summary: Failure compiling a project with cyclic dependencies
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 24832 27770 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-06-18 20:31 EDT by Tim Francis CLA
Modified: 2003-02-11 10:02 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Francis CLA 2002-06-18 20:31:38 EDT
Problem occurs in the headless F3 workbench.

I know that projects with cyclic dependencies are not normally supported,
so I set the java builder options

// Ignore 'invalid' classpaths, so we can deploy beans with cyclic dependencies
javaOptions.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);

The structure works in most cases, but I have a test case that fails.  
The error messages are:

Building project: /RetireEJB.
[*Error] /RetireEJB: The project was not built since its classpath is 
incomplete. Can not find the class file for 
com.ibm.wssvt.tc.pli.data.PersonData. Fix the classpath then try rebuilding 
this project
[*Error] ejbModule/com/ibm/wssvt/tc/pli/ejb/EJSCMPBasePersonHomeBean.java(0): 
This compilation unit indirectly references the missing type 
com.ibm.wssvt.tc.pli.data.PersonData (typically some required class file is 
referencing a type outside the classpath)
Shutting down workbench.

Execution Halted: Compilation Errors Reported
2 Errors, 56 Warnings, 0 Informational Messages

>
>Note that PersonData.class does exist, in the PersonEJB project
>
>dir PersonData.class /s/b

PersonEJB\ejbModule\com\ibm\wssvt\tc\pli\data\PersonData.class

>
>And that the PersonEJB project is in the classpath of the RetireEJB project
>
>type RetireEJB\.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="ejbModule"/>
    <classpathentry exported="true" kind="lib" path="imported_classes"/>
    <classpathentry exported="true" kind="src" path="/PersonEJB"/>
    <classpathentry exported="true" kind="src" path="/PolicyEJB"/>
...
Comment 1 Philipe Mulet CLA 2002-06-20 05:33:34 EDT
About the same time as we added support for aborting the build in presence of 
classpath inconsistencies, we also changed the builder behavior so that it 
refuses building projects for which any of its prereq projects failed to build 
before.

The reason for this is that in presence of such issues, we used to be reported 
about 30.000 errors for an Eclipse full source workspace, which is just too 
many errors for anybody to handle (first being the task list). With the new 
behavior, the error count is fairly small. 

Mutual dependencies are clearly causing you some grief, since they induce 
unbound references in classfiles. 

Note that the check for presence of a built state isn't configurable. We could 
make it optional so as to allow building your test case, but Eclipse in general 
is not meant to deal with build cycles. Indeed, each project builder gets 
activated exactly once in a build iteration. 

I recommend changing the test, to use one project and 2 source folders instead.
If you need this setting to be configurable, then please let us know, this also 
require some UI action (for surfacing this information to the end user in the 
compiler preferences). CC'ing Erich since he may be involved.

Alternatively, we could make this simply a JDT/Core option, which could be set 
only programmatically.
Comment 2 Philipe Mulet CLA 2002-06-20 07:29:54 EDT
May consider for F4
Comment 3 Philipe Mulet CLA 2002-06-20 07:41:34 EDT
One possible solution for minimizing changes would be to only check for 
presence of built state when the classpath check is done (if abort on classpath 
issue is enabled).
Comment 4 Philipe Mulet CLA 2002-06-20 09:28:37 EDT
Actually, the current implementation only checks for prereq built states, if 
abort build setting is enabled. So this must be something else. 

Tim - can you please provide a test case for investigation ? 

The missing classfile may be existing in the end, but not at the 
time /RetireEJB is built. Does an incremental build at the end fixes the 
problem ? Did this scenario work in F3 ?
Comment 5 Philipe Mulet CLA 2002-06-20 10:42:47 EDT
Did it work with F2 ?
Comment 6 Philipe Mulet CLA 2002-06-21 08:48:37 EDT
Removing F4 milestone until further information is provided.
Comment 7 Philipe Mulet CLA 2002-07-03 10:52:24 EDT
Deferring until more info is provided.
Comment 8 Jed Anderson CLA 2002-07-24 17:18:21 EDT
When I looked at the .classpath file for the PersonEJB project in the example I 
noticed that "ejbModule" folder was marked as the output folder for the 
project.  However, there is no source folder for PersonEJB, so if the compiler 
ever decides that it wants to scrub the output folder (which it can do any 
time) it will delete PersonData.class.  Later if it needs PersonData.class, it 
has no way of regenerating it from source.

I believe that the example provided should mark ejbModule as a lib classpath 
entry (i.e. <classpathentry kind="lib" path="ejbModule"/>) instead of marking 
it as the output folder.  This should allievate the problem.  Tim, could you 
please test this?

Philippe, does this make sense to you?  Also, could this example be exposing an 
ImageBuilder + cyclic dependencies bug which causes the compiler to scrub the 
output folders too many times?

Comment 9 Philipe Mulet CLA 2003-01-21 06:02:20 EST
Reopening
Comment 10 Philipe Mulet CLA 2003-01-29 12:05:52 EST
*** Bug 27770 has been marked as a duplicate of this bug. ***
Comment 11 Philipe Mulet CLA 2003-01-29 12:06:41 EST
*** Bug 24832 has been marked as a duplicate of this bug. ***
Comment 12 Philipe Mulet CLA 2003-01-30 08:58:30 EST
Fixed, thanks to build manager looping behavior addition (combined with our 
Java builder explicitely asking for another build iteration, in presence of 
cycles. Subsequent iterations are always incremental).
Comment 13 David Audel CLA 2003-02-11 10:02:25 EST
Verified.