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

Drop redundant default methods from FFM API

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 22
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      The only compatibility impact is if a client invokes the `isDefault` predicate on the reflective representation of one of the affected methods. Moreover, initialization of the superinterface might change and become more lazy as a result of the change in this CSR.
      Show
      The only compatibility impact is if a client invokes the `isDefault` predicate on the reflective representation of one of the affected methods. Moreover, initialization of the superinterface might change and become more lazy as a result of the change in this CSR.
    • Java API
    • SE

      Summary

      MemoryLayout and MemorySegment contain redundant default methods.

      Problem

      MemoryLayout and MemorySegment declare several default methods. Since these interfaces are sealed, and cannot be implemented by user code, there is no advantage to use a default method instead of an ordinary abstract method. Moreover, default method in interface cause change in interface initialization, as per JVMS 5.5. For this reason, it would be better to avoid adding default methods where not strictly required.

      Solution

      The solution is to remove the default keyword from the methods in MemorySegment and MemoryLayout and move the corresponding method bodies in the implementation classes AbstractMemorySegmentImpl and AbstractLayoutImpl, respectively.

      Specification

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Jorn Vernee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: