Bug 126999 - Compiler fails on valid multiple secondary classes in a java file
Summary: Compiler fails on valid multiple secondary classes in a java file
Status: RESOLVED DUPLICATE of bug 106446
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-08 18:44 EST by dramage CLA
Modified: 2021-03-02 04:12 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dramage CLA 2006-02-08 18:44:20 EST
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.
Comment 1 Kent Johnson CLA 2006-02-14 12:19:05 EST
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?
Comment 2 dramage CLA 2006-02-14 13:03:48 EST
(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.
Comment 3 Kent Johnson CLA 2006-02-20 15:17:42 EST
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.
Comment 4 Frederic Fusier CLA 2006-03-27 09:44:10 EST
Reopen to set as duplicate
Comment 5 Frederic Fusier CLA 2006-03-27 09:44:48 EST

*** This bug has been marked as a duplicate of 106446 ***