What is the preferred Throwable to use in a private utility class constructor?

UnsupportedOperationException sounds like the best fit, though a checked exception would be even better, since it might warn someone erroneously instantiating the class at compile time.


I like including Bloch's comment:

// Suppress default constructor for noninstantiability

Or better yet putting it in the Error:

private UtilityClass()
{
    throw new AssertionError("Suppress default constructor for noninstantiability");
}

There is an assertion: "I'm asserting that this constructor will never be called". So, indeed, AssertionError is correct here.


What about IllegalAcessError ? :)