RFR: 8345074: java.net.InterfaceAddress constructor could be made private

Chen Liang liach at openjdk.org
Sun Dec 1 01:35:38 UTC 2024


On Sat, 30 Nov 2024 18:18:29 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> Please review this PR which suggests to make the constructor of `java.net.InterfaceAddress` private.
> 
> This constructor is only accessed by native code via the `NetworkInterface` class. Making it private would express the intent of this class as being non-subclassable.
> 
> The comment of the constructor is updated to reflect the new access modifier as well as to make it clear that the constructor is not to be invoked from Java code and that instances are obtained from `NetworkInterface` via native code. 
> 
> Marking this class final is handled separately in JDK-8344943 via a CSR.

src/java.base/share/classes/java/net/InterfaceAddress.java line 46:

> 44:     /*
> 45:      * Private constructor. Not to be constructed by Java code, instances
> 46:      * are obtained from native code through the NetworkInterface class.

We should word like "this constructor is called via JNI in NetworkInterface.c" so we know what care we need to take when we update this constructor.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22467#discussion_r1864695596


More information about the net-dev mailing list