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

make jdk.net.UnixDomainPrincipal a record class

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 16
    • core-libs
    • source
    • minimal
    • `UnixDomainPrincipal` is a data class that is being changed to a record class, a new type in JDK 16
    • Java API
    • JDK

      Summary

      jdk.net.UnixDomainPrincipal is a simple data carrier class that can be changed to a record class.

      Problem

      jdk.net.UnixDomainPrincipal is a simple immutable data class that requires boilerplate methods for access. However, these methods and fields are susceptible to trivial mistakes and add to the verbosity of the class.

      Solution

      Replace the data class with a record class making the code more concise and easier to maintain.

      Specification

      The existing class is replaced in its entirety with the record code below. This code is binary compatible with the original. For the generated API doc change, please refer to the specdiff attached at the end.

      /**
       * Represents the credentials of a peer connected to a
       * <a href="../../../java.base/java/nio/channels/package-summary.html#unixdomain">
       * Unix domain</a> socket.
       *
       * @param user the user identity
       * @param group the group identity
       *
       * @since 16
       */
      public record UnixDomainPrincipal(UserPrincipal user, GroupPrincipal group) {
      
          /**
           * Creates a UnixDomainPrincipal.
           *
           * @param user the user identity
           * @param group the group identity
           *
           * @throws NullPointerException if {@code user} or {@code group} are {@code null}.
           */
          public UnixDomainPrincipal {
              Objects.requireNonNull(user);
              Objects.requireNonNull(group);
          }
      }

            pconcannon Patrick Concannon (Inactive)
            michaelm Michael McMahon
            Daniel Fuchs, Michael McMahon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: