Re: Separate interface and implemenation problem..



Steven Simpson wrote:
I've not seen a compelling reason for static methods in an interface yet.

I wonder if a statically implemented interface would suit better in some
such cases:

// Not real code
class MyClass implements static Runnable {
  public static void run() { ... }

}

But that doesn't make Java sense. Static methods don't implement or
override static methods of supertypes, nor can static methods delegate
their action to subtype static methods. In no meaningful sense in
Java, at this time, does a static method in a subtype equate to a
static method in a supertype. Instead, one hides the other. JLS
8.4.8.2:
If a class declares a static method m, then the declaration m is said
to hide any method m', where the signature of m is a subsignature (§8.4..2)
of the signature of m', in the superclasses and superinterfaces of the
class that would otherwise be accessible to code in the class.


The real question to ask is just what benefit one would expect from a
static method in an interface that isn't already available from static
methods in classes. Assuming there is such a benefit, and I can't
think of one, the next question is whether it's worth the distortion
of Java's semantics to make it work.

--
Lew



.