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

different return type error not detected

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      generic

      Description



      Name: ###@###.### Date: 09/04/96


      Java language specification (8.1.2.1 abstract Classes) says:

      "It is a compile-time error to declare an abstract class type such that
      it is not possible to create a subclass that implements all of its
      abstract methods. This situation can occur if the class would have as
      members two abstract methods that have the same method signature
      (8.4.2) but different return types. "

      See also (8.4.6.4 Inheriting Methods with the Same Signature):

      "If none of the inherited methods is not abstract, then the class is
      necessarily an abstract class and is considered to inherit all the
      abstract methods.
             - A compile-time error occurs if, for any two such inherited
             methods, either they have different return types or one has a
             return type and the other is void."

      However Java compiler doesn't recognize this situation and doesn't report error
      (but it must) in the following particular case:

      - a class has two abstract methods that have the same method signature
        but different return types,
      - and one of the methods is inherited from interface,
      - and there are no concrete subclass definition.

      See example below:

      > javac clss01003.java
      >

      ---------------------------clss01003.java-----------------------
      interface iclss01003_2 {
      abstract void foo(int par);
      }

      abstract class clss01003_b {
      abstract int foo(int par);
      }

      abstract class clss01003_a extends clss01003_b implements iclss01003_2 {
      }
      ----------------------------------------------------------------


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tturnidgsunw Todd Turnidge (Inactive)
                Reporter:
                leosunw Leo Leo (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: