Bug 20053 - interface with same-named method generates compile error
Summary: interface with same-named method generates compile error
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 F4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-12 13:11 EDT by Kevin Huber CLA
Modified: 2002-06-14 05:55 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Huber CLA 2002-06-12 13:11:23 EDT
note:  I am using Java SDK 1.4.0_01

compiling this test, TestInterface.java causes the error 
"This method has a constructor name"

This compiles fine with javac.  contents of TestInterface.java:

============================================================
public interface TestInterface {
    public void TestInterface();
}
============================================================
This version with a genuine constructor name generates the
same eclipse error "This method has a constructor name".

(note the removal of the void return argument)
============================================================
public interface TestInterface {
    public TestInterface();
}
============================================================

javac generates this error:

TestInterface.java:10: <identifier> expected
    public TestInterface();

-Kevin
Comment 1 Philipe Mulet CLA 2002-06-13 05:54:32 EDT
public interface TestInterface {
    public void TestInterface();
}

---> method has constructor name

This is only a warning, and you can turn it off in the compiler preferences 
(Window>Preferences>Java>Compiler>Errors and Warnings>Methods with constructor 
name). By default, the warning is on, since this is generally not intentional 
and rather misleading.


public interface TestInterface {
    public TestInterface();
}

---> interface cannot have constructor.
I don't see a problem with this error. Given it has no return type, this 
declaration would be a constructor (with no actual body).

Why is this a problem for you ?
Comment 2 Philipe Mulet CLA 2002-06-13 06:04:06 EDT
Closing, please reopen if you think we should not report an error.