Bug 63668 - Type <name> collides with a package name - build error
Summary: Type <name> collides with a package name - build error
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-24 09:02 EDT by kirhgoff CLA
Modified: 2004-11-24 16:47 EST (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 kirhgoff CLA 2004-05-24 09:02:57 EDT
Eclipse M8 (M9)
I guess this is very hard to reproduce (I should attach my all project) but 
this error make me spend about a day on creating a project. Also error is 
unstable (I live some time without it and then it suddenly appeared).

I have a project with some source fodler linked via variable and building code 
into other linked folder (classes). Another project depends on the first 
project and refernces other source folders via variables. It buils its code 
into classes folder too and it uses it like a class fodler (I know thats not 
good method, but I was unable to make something better).

At some fodler I have a class named Jurisdiction. At some place I have a fodler 
bnamed jurisdiction (as a part of a package name). When I compile both project 
I get "type Jurisdiction collides with a package name". As I know Java doesnt 
deny packages and classes with the same name, so I guess this is a bug.
Comment 1 Kent Johnson CLA 2004-05-25 17:44:27 EDT
Well actually Java doesn't allow names collisions between types and packages. 
You cannot have a package named p1.p2 & a type p1.p2

Try a full build of your project to see if the error appears 
(Choose 'Clean...' from the project menu)...
Comment 2 kirhgoff CLA 2004-05-26 03:33:46 EDT
and the case of words has no meaning - I mean - my class is Jurisdiction and 
the package jurisdiction.

I guess this is a bug, becasue right now I have the same code compiling ok. But 
when the projects structure is a very compilcated, it appeared.

I am not insist - I am working ok right now, I just wanted to notify you guys 
about the problem. If you think this is not the problem, please just close it.
Comment 3 Kent Johnson CLA 2004-05-26 09:57:27 EDT
Let's start over... when does the problem appear? Can you reproduce it now by 
doing a full build?

What exactly is the error message?
Comment 4 kirhgoff CLA 2004-05-26 10:16:06 EDT
OK. :)
I am working on Windows XP, JSDK1.3.2, Eclipse M9(M8 has the same problem)
Key feautures
1) Two projects. Both refer source code, libraries and other resources via 
variable-based paths.
2) One project depends on another.
3) output fodler for one project is used as a library class folder in both 
projects.
4) I have class Jurisdiction and package containing jurisdiction 
(xxx.jurisdiction.xxx)

Making full build causes "type Jurisdiction collides with a package name" 
errors in problems pane and thus other classes cannot resolve Jurisdiction 
class. A lot of errors.

Right now I created one project (merged both into one) and everything compiles 
OK. I am afraid it will not be easy to reproduce this bug, and I cannot help 
you a lot because my project is about 6000 classes. Just trying to keep you 
informed. I could live without it.
Comment 5 Kent Johnson CLA 2004-05-26 10:38:42 EDT
Well we are close to shipping 3.0 so we would like to track this down if you 
have the time to help out...

What is the package of the class Jurisdiction?

What do you mean by this: "3) output fodler for one project is used as a 
library class folder in both projects." ?

You do not need to add the output folder of project A to the classpath of 
project B... just add it as a required project.
Comment 6 kirhgoff CLA 2004-05-26 11:02:33 EDT
I mean that both projects build code into one folder referenced via variable in 
both problems.
There are two classes - bol.layer.Jurisdiction and bol.product.Jurisdiction
The package that collide with the class is 
bol.statics.instrument.rules.actions.jurisdiction. All of them are in the same 
project (and in the same source folder).

All the code is bundled in the same folder "classes".
Both projects build into it. 

About the bug itself. Right now I have a lot of work, but I will try to 
reproduce the problem in small sample projects. Just give me time - several 
days. I will try to do this and attach the code to the bug.
Comment 7 Kent Johnson CLA 2004-05-26 11:26:42 EDT
Given the names of the types & package... this is not a collision case.

If I understand you correctly, you have project A's output folder set to the 
same directory as project B's, correct?

If so, this is a VERY BAD IDEA.

When we do a full build of a project, we delete the entire contents of the 
output folder. We do not expect there to be other .class files from another 
project.

Is there some reason you need to do this? Why can you not have 2 output 
folders on your runtime path?
Comment 8 kirhgoff CLA 2004-05-26 11:42:54 EDT
I guess this is not the case - I turned off cleaning projects output directory 
on rebuild.
Comment 9 Kent Johnson CLA 2004-05-27 10:33:35 EDT
Can you try one more thing for me?

From the search menu (light bulb on task bar), find any declarations of the 
package '*.Jurisdiction'. Make sure its a case sensitive search.

Do you find any?
Comment 10 kirhgoff CLA 2004-05-27 11:04:22 EDT
0 references
*.Jurisdiction
*.Jurisdiction.*
*.jurisdiction.*

3 references
*.jurisdiction

I ve searched with All occurances/package/case sensitive

Comment 11 Kent Johnson CLA 2004-05-27 11:19:13 EDT
Do you have any Ant jobs or anything else writing folders/files in the output 
folder?

When you get the error on a type, can you look in the output folder & see a 
package by that name?
Comment 12 Kent Johnson CLA 2004-05-28 11:52:21 EDT
Please reopen if you can provide a reproduceable testcase.
Comment 13 kirhgoff CLA 2004-05-31 02:24:12 EDT
Yes I have such jobs.
My project has an ant project that clean all the output folder and generate a 
lot of sources and compile all the code (generated and existant) into it.
After that I open Eclipse, refresh the project (it start rebuilding all the 
source code) and after that found a lot of errors caused by "type name 
collides ...". 
Comment 14 Kent Johnson CLA 2004-05-31 08:01:03 EDT
So is it possible that the ant jobs are creating a package that collides with 
your type?
Comment 15 kirhgoff CLA 2004-05-31 08:08:11 EDT
Yes, but the names are different in the means of case - package name is 
lowercase(jurisdiction), class name is Jurisdiction. Or this is the case? 
anyway right now package name doesnt collides with class name, though both are 
exists in project.
Comment 16 Andrey Loskutov CLA 2004-11-22 16:02:42 EST
Ok, I have slightly diffeent test case - without linked folder etc.

Assume I have package "a" with both source "A.java" *and* the folder "A" inside, 
like here:
-a
 |-A.java
 |-A
   |-some properties
   |-some xml etc.

The source folder "a/A" is excluded from java build path, so that it cannot be a 
"valid" package for Eclipse, and I really wan't have any *.java files in this 
package, only properties and xml. But I have the same problem like Kirill - 
Eclipse compiler reports "The type A collides with a package" and wan't go 
further. With Ant I can build/deploy my application without any warning.
I think this is a bug.

Tested with Eclipse 3.1M3 on Jdk 1.5 for WinXP.
Comment 17 Kent Johnson CLA 2004-11-24 15:09:40 EST
Andrei: can you please show us your .classpath file.

Because your example works fine for me when I specify an exclusion pattern of

	<classpathentry excluding="a/A/*" kind="src" path=""/>
Comment 18 Andrey Loskutov CLA 2004-11-24 16:00:51 EST
Damn, I have forgotten that I have a test cases directory and there test/a/A, 
and this one was not excluded from build path.

Sorry for the bad example.

But anyway - why it is not ignored by compiler - neither of them does have a 
java.* files inside?
Comment 19 Kent Johnson CLA 2004-11-24 16:47:13 EST
We do not ignore packages just because you have yet to define a new .java file.

It leads to strange errors when you do create the first Java class in a 
previously empty package.

Closing.