Bug 20053

Summary: interface with same-named method generates compile error
Product: [Eclipse Project] JDT Reporter: Kevin Huber <kevin.huber>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 F4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

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.