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

Make Executable.getParameterCount() actually abstract

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 20
    • core-libs
    • None
    • binary, behavioral
    • minimal
    • If there were other potential subclasses of Executable, this change would be source incompatible, but Executable is now sealed so that is not a concern.
    • Java API
    • SE

    Description

      Summary

      Change Executable.getParameterCount to be declared to be an abstract method, matching its semantics.

      Problem

      While Executable.getParameterCount is conceptually an abstract method, it is not coded as such, which is confusing. Since Executable is now sealed, only the implementation in Mehtod and Constructor are relevant.

      Solution

      Change the method to be declared as abstract.

      Specification

      --- a/src/java.base/share/classes/java/lang/reflect/Executable.java
      +++ b/src/java.base/share/classes/java/lang/reflect/Executable.java
      @@ -253,9 +253,7 @@ public abstract sealed class Executable extends AccessibleObject
            * @return The number of formal parameters for the executable this
            * object represents
            */
      -    public int getParameterCount() {
      -        throw new AbstractMethodError();
      -    }
      +    public abstract int getParameterCount();
      
           /**

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              webbuggrp Webbug Group
              Alan Bateman, Iris Clark
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: