Ricardo said:
What I'm saying is that providing a class with an interface where a
class method is called from an instance (which is legal), should be safe
enough that *a user* would not be trapped and swallowed by a black hole.
Probably making a big mistake joining this thread, but there are several
misconceptions there. The interface of the class does is not the one that
allows you to call the class method with a syntax that looks like it is
calling an instance method. It is the language. There is nothing the
interface can do about it.
You certainly can make a credible argument that perhaps it should have been
called Thread.sleepCurrentThread() to make it more explicit. To which all we
can say is hindsight is 20/20. It is too much of a leap to then say that we
should use misleading syntax to compensate.
And there is an error in your statement. The class method is not called from
an instance at all. The static method is called according to the type of the
variable not by the type of the instance. The variable could even be null.
Here is another way that the syntax could lead to confusion. Consider if we
for some reason wanted to do logging of operations on Threads. So we might
create:
public class LoggedThread extends Thread
{
public static void sleep( long millis ) throws InterruptedException
{
log( "Thread going to sleep" );
Thread.sleep( millis );
log( "Thread woken up" );
}
...
Some unsuspecting user used might do:
Thread myThread = new LoggedThread( someRunnable );
...
myThread.sleep( 500 );
They will probably have trouble figuring out why the logging messages do not
show up.