Community
Participate
Working Groups
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.
*** Bug 3037 has been marked as a duplicate of this bug. ***
*** Bug 3371 has been marked as a duplicate of this bug. ***
*** Bug 3419 has been marked as a duplicate of this bug. ***
*** Bug 5036 has been marked as a duplicate of this bug. ***
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.
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.
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...
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.
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.
We're now detecting class file collisions.