Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4259688

Java Compiler gives misleading error messages.

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      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)
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            wmaddoxsunw William Maddox (Inactive)
            Reporter:
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: