-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.2
-
generic
-
generic
Name: skT88420 Date: 08/04/99
Consider the following interface:
import java.awt.*;
public interface MyInterface {
Component getComponent();
}
And in a separate file a class implementing that interface:
// import java.awt.*;
public class MyClass implements MyInterface {
public Component getComponent() {
return null;
}
}
When you compile these two files with javac, it reports an error:
MyClass.java:6: The method Component getComponent() declared in
class MyClass cannot override the method of the same signature
declared in interface MyInterface. They must have the same
return type.
public Component getComponent() {
^
1 error
The error in file MyClass.java is the missing import (it was
commented out in the example) which causes javac to not find
java.awt.Component class. Looking at the error message leads
you to believe that you've incorrectly typed the method's
descriptor in MyInterface. Took me a while to realize it was
a missing import causing this, not anything wrong with my
class or my interface. I believe this error message is
misleading.
(Review ID: 93271)
======================================================================