Bug 6799 - Duplicate type collisions
Summary: Duplicate type collisions
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 3037 3371 3419 5036 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-12-11 11:33 EST by Kent Johnson CLA
Modified: 2002-02-11 04:52 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Johnson CLA 2001-12-11 11:33:09 EST
Currently when 2 types collide, the collision error is only reported when their 
2 files are compiled together.

There are several cases with auto-build on when no error is reported.

Case #1:
- create a file A.java with a public type A and secondary type B, then
- create a file B.java with a public type B -> a collision error should be 
reported

Case #1b:
- rebuild the entire project from the above testcase so the error exists, then
- remove the secondary type B from A.java -> the collision error should be 
removed

Case #2:
- create a file A.java with a public type A, then
- create a file B.java with a public type B, then
- add a secondary type B to the file A.java -> a collision error should be 
reported

Case #3:
- perform all the above testcases with A.java defining only a public type A, 
and B.java defining a public type B and secondary type A,
- the order in which the files are defined can affect which file is tagged with 
the collision error

This PR was added to merge several similar cases into one PR.
Comment 1 Kent Johnson CLA 2001-12-11 11:38:57 EST
*** Bug 3037 has been marked as a duplicate of this bug. ***
Comment 2 Kent Johnson CLA 2001-12-11 11:53:10 EST
*** Bug 3371 has been marked as a duplicate of this bug. ***
Comment 3 Kent Johnson CLA 2001-12-11 11:54:08 EST
*** Bug 3419 has been marked as a duplicate of this bug. ***
Comment 4 Kent Johnson CLA 2001-12-11 11:55:49 EST
*** Bug 5036 has been marked as a duplicate of this bug. ***
Comment 5 Kent Johnson CLA 2002-01-16 13:56:03 EST
Also need to detect resource collisions which do not cause type collisions.

With multiple source folders, the following case is possible:

- create a file src1/p1/A.java with a secondary type B, then
- create a file src2/p1/A.java with a public type A.

If the compiler must search for the type A, the lookup environment will answer 
src1/p1/A.java instead of src2/p1/A.java because of the main typename match. 
Secondary types are only found as .class files.
Comment 6 Kent Johnson CLA 2002-01-17 12:20:03 EST
Is this case a problem?

src1/p1/A.java defines class B {}
src1/p1/B.java defines class A {}

Can a file define a secondary type named X if a file named X exists in the same 
package?

The batch/incremental builders may have problems if both files are not compiled 
together or before anyone references either type A or B.

There are no .class file collisions so we have to detect this case when 
gathering files.
Comment 7 Kent Johnson CLA 2002-01-17 12:23:17 EST
Is this case a problem?

src1/p1/Helpers.java defines class SimpleHashtable {}
src2/p1/Helpers.java defines class SimpleVector {}

Can 2 filenames collide if none of their generated .class files collide?

Same issues as the case above...
Comment 8 Kent Johnson CLA 2002-01-18 10:47:25 EST
So after some discussion, we will detect class file collisions only.

While possibly adding a warning to a source files which only define secondary 
types.
Comment 9 Kent Johnson CLA 2002-01-18 11:43:10 EST
Since the batch/incremental builders will be detecting class file collisions & 
as a result not writing out some class files. Its possible that runtime errors 
will occur because mismatched class files will exist.

The case is... assume A.java has already been compiled & A.class has been 
saved. Now in the next compile loop, compile B.java (which defines A) & C.java, 
which references fields/methods in the secondary type A. Since the second 
A.class will not be written but C.class will be, runtime errors will occur.
Comment 10 Kent Johnson CLA 2002-01-28 17:42:05 EST
We're now detecting class file collisions.