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

Cannot directly invoke the abstract method using super keyword.

XMLWordPrintable

    • x86_64
    • windows_8

      ADDITIONAL SYSTEM INFORMATION :
      Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Not able to call a method of the super class which is abstract using keyword SUPER.

      For ex -

      ConcreteHandlerThree extends BookHandler
      ConcreteHandlerThree - Concrete class
      BookHandler - abstract class having - public abstract void handleRequest(Request request);
      calling super.handleRequest(request ) errors - Cannot directly invoke the abstract method using super keyword.
      super.handleRequest(request) gives an error

      REGRESSION : Last worked in version 8u181

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should be able to call to the super class using super keyword
      ACTUAL -
      Cannot directly invoke the abstract method using super keyword.

      ---------- BEGIN SOURCE ----------
      MAIN CLASS -
      BookHandler h1 = new ConcreteHandlerOne();
      BookHandler h2 = new ConcreteHandlerTwo();
      h1.setSuccessor(h2);
      h1.handleRequest(new Request("Negative Value ", -1));

      Abstract class - BookHandler
      protected BookHandler m_successor;
      public void setSuccessor(BookHandler successor)
      {
      m_successor = successor;
      }

      public abstract void handleRequest(Request request);


      Concrete Class
      @Override
      public void handleRequest(Request request)
      {
      if (request.getValue() < 0)
      { //if request is eligible handle it
      System.out.println("Negative values are handled by ConcreteHandlerOne:");
      System.out.println("\tConcreteHandlerOne.HandleRequest : " + request.getDescription()
      + request.getValue());
      }
      else
      {
      super.handleRequest(request); - ERROR IN THIS LINE . NOT ABLE TO CALL SUPER CLASS
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: