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

Make some ClassDesc methods no longer default

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • None
    • source
    • minimal
    • Changes to inheritance-related modifiers in methods in a sealed hierarchy have no user impact.
    • Java API
    • SE

      Summary

      Mark some ClassDesc methods, whose implementations are now specialized into subclasses in the sealed hierarchy, as abstract.

      Problem

      ClassDesc is getting specific implementations; some previous default implementations are better converted to non-concrete abstract methods and be overridden in implementations instead.

      The implementation specification of displayName is no longer applicable to non-default methods.

      Solution

      Make these methods in ClassDesc abstract (non-default):

      • arrayType()
      • arrayType(int)
      • displayName()

      For displayName(), promote the implementation specification to the API specification. There are other inconsistencies in this API method, but we decide to address such issues in another RFE and its dedicated CSR instead of here.

      Specification

      -    default ClassDesc arrayType() {
      +    ClassDesc arrayType() {
      -    default ClassDesc arrayType(int rank) {
      +    ClassDesc arrayType(int rank) {
      -     * Returns a human-readable name for the type described by this descriptor.
      -     *
      -     * @implSpec
      -     * <p>The default implementation returns the simple name
      -     * (e.g., {@code int}) for primitive types, the unqualified class name
      -     * for class or interface types, or the display name of the component type
      -     * suffixed with the appropriate number of {@code []} pairs for array types.
      -     *
      -     * @return the human-readable name
      +     * {@return a human-readable name for this {@code ClassDesc}}
      +     * For primitive types, this method returns the simple name (such as {@code int}).
      +     * For class or interface types, this method returns the unqualified class name.
      +     * For array types, this method returns the human-readable name of the component
      +     * type suffixed with the appropriate number of {@code []} pairs.
            */
      -    default String displayName() {
      +    String displayName() {

            liach Chen Liang
            liach Chen Liang
            Jorn Vernee, Mandy Chung
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: