Community
Participate
Working Groups
This is a tough bug to describe, so my apologies in advance. The Java language spec allows multiple top-level classes to be written in a single .java file as long as only the main one is public. For example: --- begin Bob.java --- public class Bob { } class BobSecondClass { } --- end bob.java --- In this example, BobSecondClass is package-private, so it may legally be accessed from other .java files in the same package. I'm currently working with a closed repository that makes use of referencing such secondary package-private classes defined in other .java files. It compiles without incident with javac, but the Eclipse compiler marks all references to secondary package-private classes with errors (class def not found) after a clean build. All references are marked with an error - including references to that class in other classes within the same .java file. However, it *does* know where the definitions are, because I am able to ctrl-click navigate to the definition. If I then change the class name and change it back (e.g. adding and deleting a space in the middle of the secondary class name) and then save, the file is compiled correctly and all references elsewhere in the package work as expected. A clean build causes the errors to return, and necessitates a repeat of the workaround. This bug occurs with Eclipse 3.2M4, as well as 3.1, with all versions of Sun's JDK 1.5 that I've tried (including 1.5.0_05). I have been unable to reproduce the error condition in a new project, but it is a significant headache preventing Eclipse adoption among developers working on our existing code base. Please don't hesistate to contact me for clarification as necessary.
The JDT builder splits very large projects into multiple compile loops (1000 files at a time) to reduce the amount of memory needed to compile them. If the files that define the secondary types are not in the first group of files then they cannot be found by name since their filename does not match. Does your project have more than 1000 source files?
(In reply to comment #1) > Does your project have more than 1000 source files? > Yes, the project has 2088 source files, so the explanation certainly sounds plausible.
The builder will now detect the secondary types compiled after the first group of types and recompile types dependent on them after the batch build is finished.
Reopen to set as duplicate
*** This bug has been marked as a duplicate of 106446 ***