Bug 169477 - Incorrectly errors for multiple public classes that are not concrete
Summary: Incorrectly errors for multiple public classes that are not concrete
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 M2   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, ui
Depends on:
Blocks:
 
Reported: 2007-01-03 15:49 EST by Kathy Haines CLA
Modified: 2007-09-17 08:15 EDT (History)
2 users (show)

See Also:


Attachments
This file compiles and runs without errors Eclipse finds an error on line 8 (552 bytes, text/plain)
2007-01-03 16:06 EST, Kathy Haines CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kathy Haines CLA 2007-01-03 15:49:16 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Create a public class. Example, a file called "MyClass.java" with a class declaration:
public class MyClass { }
2. In this same file, create a public interface or a public abstract class. This definition must use the word "public" to reproduce the error. For example:

public interface MyInterface { }

or 

public abstract class MyAbstract { }
3. You should get an error for the abstract class/interface you created in step two such as "The public type MyAbstract must be defined in its own file." 


More information:
Despite the error that Eclipse gives you, the compiler takes this code. And even when you use these classes - not just define them - it takes the code. 

It appears the correct rule is, a class (such as "MyClass.java") can have only one CONCRETE public class, but it can have zero to many public interfaces and/or zero to many public abstract classes in the same file. These public abstract classes and interfaces do not have to match the name of the file.

Along these lines, I did not test what happens when these zero to many public interfaces and abstract classes are the solely defined classes within one file. That is to say, if a public interface or a public abstract class is the only class defined within a file, does its class name have to match the file name? I'm not sure what the rules are for this scenario.

Lastly, I also found, even though the following declarations have the same meaning to the compiler, Eclipse only seems to have a problem when the keyword "public" is present:

public abstract inteface MyInterface { } * error
public interface MyInterface { }         * error
interface MyInterface { }                * no error
abstract interface MyInterface { }       * no error
Comment 1 Kathy Haines CLA 2007-01-03 16:06:45 EST
Created attachment 56352 [details]
This file compiles and runs without errors Eclipse finds an error on line 8
Comment 2 Kent Johnson CLA 2007-08-30 13:31:29 EDT
If I understand the issue correctly - your complaint is the code should not execute because of the public type name error - correct ?

Its not an issue that we're failing to report the public type name error.


We won't be changing this behaviour since there are several cases with problem types that we want users to debug these types, even though they have errors.
Comment 3 Maxime Daniel CLA 2007-09-17 08:15:14 EDT
Verified for 3.4M2 using build I20070917-0010.