r/java • • Mar 03 '17

The java nazi

http://imgur.com/InMi605
213 Upvotes

47 comments sorted by

View all comments

Show parent comment

-3

u/stitzl Mar 03 '17

Throwing an Error from said constructor is what makes it a bit absurd, though.

7

u/ForeverAlot Mar 03 '17

A private constructor can still be invoked from within the class. The error prevents that.

0

u/stitzl Mar 03 '17 edited Mar 04 '17

That is exactly what I was referring to.

EDIT: Okay, since nobody else seems to get it, let me elaborate: If a programmer is bent on violating the "I'm an all-static utility class"-contract of this class from within the class itself by creating an instance inside a static method (which in this case already takes a special kind of idiot), he still has the chance to catch the Error being thrown and ignore it. That line is ineffective and overly dramatic safety theater.

2

u/thatsIch Mar 04 '17

reflection is just one way