On Wed, 29 Mar 2023 08:13:06 GMT, Per Minborg <pminb...@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

Reply via email to