Bug 131760 - import cannot be resolved, but package and class exists
Summary: import cannot be resolved, but package and class exists
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-03-14 13:09 EST by Harold Williams CLA
Modified: 2009-08-30 02:07 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harold Williams CLA 2006-03-14 13:09:29 EST
This may be similar to bug 130309.

We have a project with a signifanct number of classes (over 1000). We have a package structure similar to what follows:

com.ezrez
com.ezrez.a.some.packages
com.ezrez.common
com.ezrez.d.other.packages

We have a problem that when we clean the project and it rebuilds, classes in packages *before* com.ezrez.common (alphabetically) are OK but classes in packages *after* com.ezrez.common get compiler errors: "The import com.ezrez.common cannot be resolved". 

However the class in com.ezrez.common *does* exists and if you add a space to the error class it recompiles and is happy. If you incrementally go and add spaces to the (hundreds of) files with these errors, you will see the number of reported errors go down until Eclipse somehow decides that it should do a clean and rebuild, at which point we are back wehere we started.

I experimented and created a class that referenced a class in common. I duplicated this class and put it in various packages. I put it in com.ezrez, com.ezrez.a, and com.ezrez.z. The classes in com.ezrez and com.ezrez.a compiled fine; the class in com.ezrez.z failed with the error I described above. Again, if I added space to this class after the clean and saved it it compiled ok and the error went away.

I can't, unfortunately, send you the source to our project and it has been very hard to characterize what causes this bug. I don't know how to tell you to reproduce it, but it is very serious. I have been able to find a discussion using google about this exact bug and no one could really find a workaround. I recently had to change the way our project was structured get things to compile. Without the changes, we could never get errors out. I am fearful that we might add some code that leads to a situation where we can't figure out a way to restructure things so we can get it to compile.

If you want to discuss this with me, please feel free to contact me. If we have to, we might be able to figure out a way to obfuscate our code so we could give it to you (no guarantees).

This is a potentially lethal bug for us.

Thanks,

E. Harold Williams

P.S. some links for other people with this bug:
http://dev.eclipse.org/newslists/news.eclipse.helpwanted/msg00102.html
http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg06210.html
http://www.brunningonline.net/simon/blog/archives/001748.html
Comment 1 Olivier Thomann CLA 2006-03-14 13:15:12 EST
What build are you using?
Is it 100% reproducable?
Does it fix it if you remove the .index files in .metadata\.plugins\org.eclipse.jdt.core and you restart your workspace?

If it is reproducable, can you provide a test case that we could use to reproduce it?
Comment 2 Gilles WIART CLA 2006-07-05 04:27:34 EDT
This is the same for me. 

Sometimes, some classes cannot be compiled and the compiler says "import x.y.z cannot be resolved" even if class "x.y.z"  is included in classpath.

Workarounds are :
 - when "x.y.z" is in a library, delete this library from classpath and add it again in classpath ;
 - move the line "import x.y.z" in source, or add a blank space after it

But the problem occurs again after a while :-(
Comment 3 Jerome Lanneluc CLA 2006-07-18 10:29:49 EDT
Please reopen with build ID and steps to reproduce the problem.
Comment 4 Denis Roy CLA 2009-08-30 02:07:55 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.