RFR: 8305157: The java.util.Arrays class should be declared final
Raffaello Giulietti
rgiulietti at openjdk.org
Wed Mar 29 16:27:31 UTC 2023
On Wed, 29 Mar 2023 08:13:06 GMT, Per Minborg <pminborg at openjdk.org> wrote:
> Non-instantiable utility classes should be declared `final` and have a private constructors.
>
> See Effective Java, Third Edition, Joshua Bloch (for example, Item 19 or Item 22).
In some future, one could mistakenly instantiate the class from some new method in the class itself.
Throwing protects against such mistakes already during testing, avoiding a reviewer to purposely checking that the empty constructor is never invoked.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13221#issuecomment-1488920408
More information about the core-libs-dev
mailing list