Bug 142023 - Failure to resolve indirectly referenced type
Summary: Failure to resolve indirectly referenced type
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-16 12:25 EDT by Igor Fedorenko CLA
Modified: 2006-05-18 07:31 EDT (History)
2 users (show)

See Also:


Attachments
sample projects that demonstrate the problem (3.25 KB, application/octet-stream)
2006-05-16 12:27 EDT, Igor Fedorenko CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Fedorenko CLA 2006-05-16 12:25:43 EDT
I have three java projects in my workspace -- A, B and C. B uses some classes from A, C uses some classes from B. This setup works fine with 3.1.2 but in 3.2 RC4 I get "The type XXX cannot be resolved. It is indirectly referenced from required .class files" compile error. Major regression from 3.1. I'll attach trivial test case to demo the problem shortly.
Comment 1 Igor Fedorenko CLA 2006-05-16 12:27:05 EDT
Created attachment 41605 [details]
sample projects that demonstrate the problem
Comment 2 Kent Johnson CLA 2006-05-16 14:26:09 EDT
This is another case of bug 137710 where 2 methods have the same name but take unrelated parameters. The best solution is to rename one of the methods since the parameters are not related at all, unlike a normal overload case when one type is a subtype of the other.

In 3.1.2, the 2 methods appear in a different order in the table than 3.2 so we end up resolving the parameters for importData(TaskDefinition data) before importData(String data).

It compiles in 3.2 if you change the order of the methods, but the best solution is to rename one of the methods.
Comment 3 Philipe Mulet CLA 2006-05-17 10:57:27 EDT
This is a borderline situation. However, in theory our sorting algorithm is stable, and should sort equivalent methods (selector, arity) in order of definition.

Need to check for 3.2.1. 
Comment 4 Kent Johnson CLA 2006-05-17 12:00:09 EDT
Igor, after discussing this issue we've decided the correct solution for this problem is to rename one of the two methods.

Our method lookup algorithm is order dependant in this case so the error you're seeing can appear any time you change the order of the methods in the file.

If you're switching between 3.1 and 3.2, there is no order which will compile in all cases, unless you rename one of the methods.
Comment 5 Igor Fedorenko CLA 2006-05-17 13:10:46 EDT
First, I do not understand why a tool would tell me how to name my methods, let alone require specific order in which I define methods in .java file. For the record, in this particular case the two methods implement basically the same logic with the only difference being parameter format (java object in one case and XML rendering of the object in the other), so I have all the reasons to name these methods the same.

Second, JDT has enough information to resolve TaskDefinition if it really needs to. JDT chooses not to follow project dependencies for type resolution and this I believe is the root cause of this problem. Btw, there is a similar/related bug 73957 agains PDE which seems to have the same root cause and which is being ignored for more than a year.

If you do not have immediate solution to the problem -- that's fine, but don't pretend there is no problem at all.
Comment 6 Philipe Mulet CLA 2006-05-18 04:30:47 EDT
Igor,

To reiterate. The classpath is incomplete, and a required type is missing from there. Since we lazy resolve pieces as we perform lookups, you are observing the consequence of an implementation detail. The Java spec doesn't tell anything, ie. it is up to each compiler vendor to be as resilient as he can. For instance, javac is always failing in this situation.

Comment 7 Philipe Mulet CLA 2006-05-18 04:35:39 EDT
Bug 73957 belongs to PDE. Until PDE correctly provides the required binaries on the classpath, what you are seeing here is not going to change.

PDE owns the definition of your classpath here.
CC'ing Wassim, since this is just another symptom of bug 73957, for which the solution has to come from PDE I believe.

Until now, you were lucky that JDT was resilient (again more than other compilers). I agree that reording methods or renaming them feels a bit of a hack, it is just a way to workaround the PDE current limitation. A better solution is for PDE to add the necessary pieces to your classpath.
Comment 8 Wassim Melhem CLA 2006-05-18 06:51:31 EDT
We should find a resolution for bug 73957 one way or another in 3.3

One reason why I'm hesitant to put all the extra JARs on the classpath is that we would have to update classpaths for plugins more often than is really necessary.

For example, now we only update the classpath of plugin X when one of its direct dependencies as changed.  By putting all the indirectly referenced JARs directly on the classpath, classpath of plugin X would have to be updated when any one of this long list of plugins is updated.

Another reason is performance/memory. If you look at the dependency graph of plugins in big products, each plugin already has a direct dependency on a lot of plugins.  If we were to bring in all the "indirect dependencies" as well, this would result in a huge classpath and a very long list of JARs which JDT would have to index.
Comment 9 Philipe Mulet CLA 2006-05-18 07:31:54 EDT
Re:indexing. If the JAR is present elsewhere anyway, we will only index it once, and thus there should not be any overhead for subsequent references to it.