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);
}
}
- csr of
-
JDK-8254996 make jdk.net.UnixDomainPrincipal a record class
- Resolved