On Thu, 24 Aug 2023 08:53:53 GMT, Andrey Turbanov <aturba...@openjdk.org> wrote:

> A few classes in `com.sun.crypto.provider` package have non-final fields 
> which could easily be marked `final`.

src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java line 276:

> 274:     }
> 275: 
> 276:     private void parseKeyBits() throws InvalidKeyException {

This method is only called once inside the constructor, considering that this 
method is kind of trivial, maybe you can just move the impl to the constructor 
and remove this method.

src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java line 57:

> 55: 
> 56:     // the key bytes, without the algorithm information
> 57:     private final byte[] key;

Same comment about re-assignment, please don't add the final keyword to this 
field.

src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java line 268:

> 266:     }
> 267: 
> 268:     private void parseKeyBits() throws InvalidKeyException {

Same comment about moving this code block to constructor since it's only used 
once and the small size.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15412#discussion_r1350892266
PR Review Comment: https://git.openjdk.org/jdk/pull/15412#discussion_r1350902339
PR Review Comment: https://git.openjdk.org/jdk/pull/15412#discussion_r1350909325

Reply via email to